The following are some of the questions asked in Investment Banking Technical Interview
Q 1) What is the difference between notify and notifyall?
Answer) notify will notify randomly any one thread in the pool of waiting threads
notify all will notify all threads in the wait set but each thread will obtain lock one after the other and execute the code after the wait() method call within synchronized block
Q 2)can we override wait , notify and notify all
Answer) no you cannot they are final methods in object class
Q3 )how will you find out return value from a thread?
Answer) Use Future.get and create the task using Callable instead of Runnable
Q 4)whats is a deadlock ? and how can you avoid it using JDK1.5 api
Answer) using Lock and ReentrantLock we can create nested locks
Q 5)what is the equivalent of join method in jdk1.5 api?
Answer) countdown latch
Q 6) what is the difference between wait and sleep?
Q 7) what is threadlocal variable?
Q 8) what is volitile variable?
Q 9) how can you implement ThreadPool in java?
Q 10)what is the importance of tryLock method in Lock Interface
Q 11)how does LinkedBlockingQueue achive concurrency?
Q 12) can we have instance lock and class lock at the same time?
Q 13) how do you stop a thread?
Q 14) what happens when there is an exception in thread ?
Collections Questions
What is the Difference between ArrayList and LinkedList.?
What is the differece between HashMap and Hashtable?
how do you delete from a Hashmap?
Why do we need to implement Equals and HashCode?
Can we put in hashMap without implementing Equals and hashCode?
What happens if we dont implement Equals but implement hashCode and then put in HashMap?
What happens if we implement Equals method but dont implement hashCode and put in Hashmap?
How Does ConcurrentLinkedQueue Work?
How does ConcurrentHashMap Work?
What is COW Copy on Write ?
What is CAS Compare and swap?
How do you implement a BlockingQueue?
What is the maximum value ArrayList can take?
How does Java Implement TreeMap?
How do you Reverse a LinkedList?
How do you find the Midpoint of a LinkedList the most efficient way?
How do you find weather a LinkedList is a Circular LinkedList or not?
Among Hashtable, Collections.getSynchronizedHashMap() and ConcurrentHashMap what is the order of Better performance
Which is faster ConncurrentHashMap or ConcurrentLinked Queue?
excellent article...another article i suggest is top 30 core java interview questions and answers
ReplyDelete