Difficulty: Easy
Correct Answer: Prints "Inside Thread Inside Thread"
Explanation:
Introduction / Context:
A Thread can be constructed with a Runnable target. By default, Thread.run() delegates to the target’s run() if present. However, if you subclass Thread and override run(), your override takes precedence and does not automatically call the target’s run().
Given Data / Assumptions:
Concept / Approach:
Because MyThread.run() overrides the inherited behavior, the Runnable target’s run() is never invoked in either case (unless explicitly called). Therefore, both started threads execute MyThread.run(), printing the same message twice.
Step-by-Step Solution:
Verification / Alternative check:
To invoke the target’s run(), remove the override or call super.run() inside MyThread.run(); the second thread would then print the Runnable’s text.
Why Other Options Are Wrong:
Common Pitfalls:
Assuming Thread always delegates to its target; forgetting that subclass overrides replace the delegation unless they call super.run().
Final Answer:
Prints "Inside Thread Inside Thread"
Discussion & Comments