IB Java Interview - 7 (2013)

This is my recent experience with one of top global investment bank. They were looking for technical hands on person. Interview started with career background and recent project updates. these questions were asked in first 2 rounds of technical interviews. These were telephonic rounds and each interview went for 1 hour. In senior roles definitely you should expect some design discussion. Most of the investment bank works in high throughput application, so interview was mainly focused on java concurrency, collection and threading. 

Round 1 : Technical  interview 


1) Hashmap : What will happen if we put 10K objects and if they are returning same hashcode.


2) What are drawback of Hashtable?


3) What is immutable objects? benefits?


4) How concurrentHashmap works and what is use case for same. for example if you have lots of read and less write then this collection works fine?


6) Does read of concurrentHashmap lock the block?

    No, it does not block, it gives concurrent result.

7) How to detect thread deadlock in production?

   Using visualVM which explores mbean which explains current deadlocks.

8) We have table A with 2 columns, 3 rows  and table B with 3 columns,4 rows then tell me return of

select * from A,B;
output
Total number of columns?  5
Total number of rows?  12

Round 2 : Technical interview:


1) Design high throughput trading application?


2) How to handle race condition in application?


3) How to design multi threaded application with processing incoming messages in trade version. We should always process trade id -1 version 1 before trade id -2 version 2?


4) Removing duplicates from unsorted list of integer?


5) Best way to find out if specific number exists in unsorted list of integer?


6) Please explain java 1.7 changes ?


7) how you do unit testing for your java application?


8) How to create singleton class and what if the constructor is throwing IOException? what will be best strategy to create instance of this class?


9) explain if this method is thread safe?

public static myMethod(StringBuilder sb){
  // StringBuilder is not thread safe..
}
Answer : Always remember in java method parameters are passed by value and in above case reference value is passed inside myMethod. In myMethod's caller method some other thread can still change the object which is reference by above myMethod's StringBuilder object. Remember primitive datatype are also passed by value and it's value is passed into method. Static doesn't mean "one instance", it means "no instance". A static method is one that you can call without reference to an object (i.e., an instance of the class).
     There is never more than one copy of the code for any method, whether it's static or an instance method. Multiple threads can simultaneously execute this one copy. As you say, each thread has its own stack, and local variable in a method are allocated on that stack. That means if the method declares a local variable "x", and there are ten threads running that method simultaneously, then there are ten entirely separate "x" variables.


Round 3:


1) Difference in Thread and Process?

Process
Each process provides the resources needed to execute a program. A process has a virtual address space, executable code, open handles to system objects, a security context, a unique process identifier, environment variables, a priority class, minimum and maximum working set sizes, and at least one thread of execution. Each process is started with a single thread, often called the primary thread, but can create additional threads from any of its threads.
Thread
A thread is the entity within a process that can be scheduled for execution. All threads of a process share its virtual address space and system resources. In addition, each thread maintains exception handlers, a scheduling priority, thread local storage, a unique thread identifier, and a set of structures the system will use to save the thread context until it is scheduled. The thread context includes the thread's set of machine registers, the kernel stack, a thread environment block, and a user stack in the address space of the thread's process. Threads can also have their own security context, which can be used for impersonating clients.
2) Difference in ListIterator and Iterator?
   ListIterator provides options to traverse in both direction and Iterator does in only one direction.

3) How the decorator design pattern is used in java.io ?

  Decorator design pattern is used in BufferedReader and BufferedWriter where these classes provides additional buffer level reading and writing for improved performance to underline Java.io. Reader and Writer class.

4) Difference in RESTful vs SOAP web service?

RestFul web service : This supports stateless operations. It can be used with only HTTP and HTTPS protocol. It supports multiple data formats like XML, JSON, text and HTML. Simpler to implement. REST has Ajax support. It can use the XMLHttpRequest object. Good for stateless CRUD (Create, Read, Update, and Delete) operations. Any browser can be used because the REST approach uses the standard GET, PUT, POST, and DELETE web operations. The focus is on accessing the named resources and exposing the data as a service.
SOAP Web service : Transport is platform & protocol neutral. Supports multiple protocols like HTTP(S), Messaging, TCP, UDP, SMTP, etc. Permits only XML data format, hence language neutral. You define operations, which tunnels through the  POST or GET. The focus is on accessing the named operations and exposing the application logic as a service. Has comprehensive support for both ACID based transaction management for short-lived transactions and compensation based transaction management for long-running transactions. It also supports two-phase commit across distributed resources.


No comments:

Post a Comment