Can we serialise the static members
Does not make any sense to make static  members serializable
Staic member belong to the class not the individual objects.
Why use the hashmap keys as immutable objects
Since if we use mutable objects as keys at the time of storage and over the time when we change it may point to entire different location.so suppose for key 3 value 33 is associated if this key is changed then it may point to diffrent location so to avoid this keys are immutable.
Difference save and persist
Save returns serializable entity
Persist return void
What is executerservice

Executerservice is like a threadpool.
It is a way of submitting thread for execution.It is used where asynchronous tasks need to be performed.
Executerservice has submit method.
Which returns future class instance.
Executerservice takes callable instance .
Future returns the result of thread execution

Can we synchronise the constructor

No not possible.since it will be creating lock on object being created but generally the object is not available to other thread till the time it gets created

Can we synchronise the run  method
Yes  we  can  synchronize  run method.

Types of  garbage  collection
Serial gc
Parallel gc=serial works same as parallel but the girl is done by multiple  threads.

What is  difference between notify and notify all

Notify all – will notify all waiting thread
Notify- invokes the first thread which called the wait method on the object

Join()  in multithreading

Join method in multithreading is used to pause execution of all other threads except the one which called the join method.

Why use inner classes.
Inner classes are used to hide implementation details. To increase encapsulation.
Some examples of usage of inner classes are
iterator inside list.
Listener in gui.

Spread the word if you really like this share with your friends.

5 thoughts on “Frequently asked interview questions”

Leave a Reply

Your email address will not be published. Required fields are marked *