Difficulty: Easy
Correct Answer: public void run()
Explanation:
Introduction / Context:
The Runnable interface defines the entry point executed by a Thread. Implementing classes must adhere to the exact method signature and visibility expected by the interface.
Given Data / Assumptions:
public interface Runnable { public abstract void run(); }
Concept / Approach:
Since interface methods are implicitly public abstract
, an implementing method must be declared public
. Omitting public
(package-private) would reduce visibility and cause a compile-time error.
Step-by-Step Solution:
public void run()
.Optional modifiers like @Override
may be used but do not change the required visibility and signature.
Verification / Alternative check:
Try compiling a class with void run()
(no public); the compiler reports that the method attempts to assign weaker access privileges than the interface method.
Why Other Options Are Wrong:void run()
(no public) has insufficient visibility; start()
is a Thread method, not part of Runnable; overloads like run(int)
do not satisfy the interface.
Common Pitfalls:
Forgetting to declare public
or misspelling the signature.
Final Answer:
public void run()
Discussion & Comments