What is the difference between Hashmap and Hashtable?
All the Mehods in HashTable are synchronized whereas HashMap is not thread-safe.
Another big difference is that HashMap allows null key and null values whereas HashTable does not permit null key and null values.
HashMap retrieval is not in order (random). HashTable provide ordered retrieval.
What is the difference between yielding and sleeping?
When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep()method, it returns to the waiting state.
How does a try statement determine which catch clause should be used tohandle an exception?
When an exception is thrown within the body of a try statement, the catch clauses of thetry statement areexamined in the order in which they appear. The first catch clause
that is capable ofhandling the exceptionis executed. The remaining catch clauses are ignored.
What are the other ways to create an object other than creating as new object?
By using factory method,new instance,cloning we can create new objects
What is the purpose of the wait(), notify(), and notifyAll() methods?
The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods.
0 Comments
What happens when a thread cannot acquire a lock on an object? Can the abstract class be final? What is synchronization and why is it important? Why do you create interfaces, and when MUST you use one? |