To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) A thread dies as soon as the execution of the start() method ends.
This option is incorrect because a thread continues to execute even after the start() method ends. The start() method is responsible for creating a new thread and invoking the run() method of that thread. The thread will continue to execute until the run() method completes or until it is explicitly interrupted or terminated.
Option B) A thread's priority can be specified as an argument to its constructor.
This option is correct. When creating a new thread in Java, you can specify its priority using the Thread class constructor. The thread priority range is from 1 to 10, where 1 is the lowest priority and 10 is the highest priority.
Option C) A sleeping thread can be made runnable by invoking notify().
This option is incorrect. The notify() method is used to wake up a thread that is waiting on a specific object's monitor. It does not make a sleeping thread runnable. To make a sleeping thread runnable, you need to use the interrupt() method to interrupt the sleep and resume the execution of the thread.
Option D) A thread can call notify() on an object only if it holds the lock on that object.
This option is correct. In Java, a thread can only call the notify() method on an object if it currently holds the lock (synchronized) on that object. This ensures that only the thread that has acquired the lock can notify other threads waiting on the same object's monitor.
The correct answer is: D. This option is correct because a thread can call notify() on an object only if it holds the lock on that object.