Java Investment Bank Interview - 6

Java technical interview questions for senior java developer for investment bank. This is first round of telephonic interview with one of major investment bank and the interview was taken by non-java person.

Round 1:
1) Tell me about yourself?
2) Your day to day activities?
3) Tell about your current project?
4) How you do integration testing?
5) What is your development and release cycle?
6) What is cluster index and non cluster index?
7) when to you cluster index or non cluster index?
8) Query optimisation ?
9) Design the Carom board in oops concept?
10) What are your current responsibility as team lead?

Another first round of interview with investment bank:

1) What is immutable objects?
 Immutable Object Strategy:
  1. Don't provide "setter" methods — methods that modify fields or objects referred to by fields.
  2. Make all fields final and private.
  3. Don't allow subclasses to override methods. The simplest way to do this is to declare the class as final. A more sophisticated approach is to make the constructor private and construct instances in factory methods.
  4. If the instance fields include references to mutable objects, don't allow those objects to be changed:
    • Don't provide methods that modify the mutable objects.
    • Don't share references to the mutable objects. Never store references to external, mutable objects passed to the constructor; if necessary, create copies, and store references to the copies. Similarly, create copies of your internal mutable objects when necessary to avoid returning the originals in your methods.
2) What is Comparable and comparator?
Comparable : Implements compareTo (Object obj)
Comparator : Implements compare (Object obj1, Object obj2)
Best use of comparator is where we are using library classes and we want to write our own way of object comparison.

3) HashMap vs TreeMap?
HashMap : Key and Value storage but no ordering.
TreeMap : Key and Value storage but provides ordering

4) What is caching?
This is strategy to reuse earlier created objects.

5) How to analysis prod/uat performance issue?
Use Thread Dump and analyze objects creation and stats. Use VisualVM tool to connect server directly using jmx and do analysis of memory.

6) Application raw query vs store procedure?
If we have more database centric logic then we should use store procedure.

7) Design the external feed update and one feed supersede the other source?
First of all design table with timestamp and once new data is coming update the table new data. Define the feed hierarchy in other table and basis of that do updates. 

8) Cluster and non cluster index?
Cluster index sort the physical rows in the database and this is not the case with non cluster index. 
Due to this physical sorting we can have only one cluster index.

9) What is Data partition?  
This strategy generally used with very heavy volume tables where we want to separate the data on basis of some key. Data partition can be on basis of range, hash or list of keys.

10) Difference Between Static and Volatile ?
Static Variable: If two Threads(suppose t1 and t2) are accessing the same object and updating a variable which is declared as static then it means t1 and t2 can make their own local copy of the same object(including static variables) in their respective cache, so updation by t1 to the static variable in its local cache wont reflect in the static variable for t2 cache . Static variables are used in the Object Context where updation by one object would reflect in all the other objects of the same class but not in the Thread context where updation of one thread to the static variable will reflect the changes immediately to all the threads (in their local cache).
Volatile variable: : If two Threads(suppose t1 and t2) are accessing the same object and updating a variable which is declared as volatile then it means t1 and t2 can make their own local cache of the Object except the variable which is declared as a volatile . So the volatile variable will have only one main copy which will be updated by different threads and updation by one thread to the volatile variable will immediately reflect to the other Thread. So the volatile variable is used in the Thread context .
11) How do you detect deadlocks? What tools would you use? 
I said do “Kill -3 ., and analyse if anything is deadlocked.
JConsole ultimately uses the new ThreadMXBean class's methods. One such method is findAllDeadLockedThreads(); This would give the list of threads that are in deadlock. If no dead lock is in plac,e then a null is returned. 

This is one way of knowing the information programmatically.

12) What is BFS and DFS ?

BFS : Breadth first search
DFS : Depth first search

13) Explain Hibernate second level of caching?
If we have enabled second level hibernate caching then Hibernate will use cache across sessions and If the same Entity is loaded through another session then Hibernate will not do DB call and It will use second level cache provide to load the Entity.
Use caching provider like : org.hibernate.cache.EhCacheProvider
In order to use Ehcache we have to download ehcahe.jar file .
14) Benefits of hibernate compare to direct java JDBC query?
Benefits :
1) Object Model : We can manage Database Entity as object model.
2) Performance: Hibernate is fine tune for data insert and loading.
3) Configuration : Its configuration bases so it it easy to implement.
4) Transaction : Transaction is managed by hibernate session on basis of configuation

15) How AOP works?
 AOP works on compile type weaving and it generates byte code which enable aop execution.

Details: AOP Execution.

16) On creating threading we should implements Runnable or extends Thread class?
This primarily depends on class responsibility if its main responsibility is to execute job independently then we can extends Thread class. As we know we can only extend one class in java so if we are implementing Runnable interface, we always have option to implement multiple interface and extend a class.

17) Confirm if this code will compile ?
public class Parent {
    public void test() throws FileNotFoundException {
       File file = new File("c:\test");
       FileInputStream fip = new FileInputStream(file);

public class Child {
    public void test() throws Exception {
       File file = new File("D:\test");
       FileInputStream fip = new FileInputStream(file);


Answer : No , the reason is child class overridden method can not throw exception which is higher in hierarchy compare to parent's method. 

No comments:

Post a Comment