Set - 1

Question 36 :

Can Java object be locked down for exclusive use by a given thread?

Answer :

Yes. You can lock an object by putting it in a "synchronized" block. The locked object is inaccessible to any thread other than the one that explicitly claimed it.

Question 37 :

Can each Java object keep track of all the threads that want to exclusively access to it?

Answer :

Yes. Use Thread.currentThread() method to track the accessing thread.

Question 38 :

Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written?

Answer :

Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first.

Question 39 :

What invokes a thread's run() method?

Answer :

After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

Question 40 :

What is the purpose of the wait(), notify(), and notifyAll() methods?

Answer :

The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to communicate each other.