Question 36
What is the main feature of java.util.HashMap in Java?
Option A is correct. HashMap uses hashing to store key-value pairs (Map interface). It is non-synchronized, allows 1 null key, and multiple null values.
What is the main feature of java.util.HashMap in Java?
Option A is correct. HashMap uses hashing to store key-value pairs (Map interface). It is non-synchronized, allows 1 null key, and multiple null values.
In Java multithreading, how is a new thread started so that it executes its run() method on a separate call stack?
Option D is correct. Calling thread.start() creates a new call stack and executes run() asynchronously. Calling run() directly simply runs it synchronously in the current thread.
Which interface must be implemented to define a task for execution by a Thread in Java?
Option C is correct. Runnable is a functional interface with a single method public void run(). It is implemented to pass task logic to Thread constructors.
Which keyword in Java provides mutual exclusion by locking an object or block for multithreaded access?
Option C is correct. The 'synchronized' keyword uses object monitor locks (intrinsic locks) to ensure only one thread executes a synchronized method or block at a time.
Which of the following packages is automatically imported into every Java program without explicit import statements?
Option B is correct. The java.lang package contains essential classes (System, String, Object, Math, Thread) and is implicitly imported into all Java source files.