Java Programming - Threads - Discussion

9. 

Which method must be defined by a class implementing the java.lang.Runnable interface?

[A]. void run()
[B]. public void run()
[C]. public void start()
[D]. void run(int priority)

Answer: Option B

Explanation:

Option B is correct because in an interface all methods are abstract by default therefore they must be overridden by the implementing class. The Runnable interface only contains 1 method, the void run() method therefore it must be implemented.

Option A and D are incorrect because they are narrowing the access privileges i.e. package(default) access is narrower than public access.

Option C is not method in the Runnable interface therefore it is incorrect.


Sid said: (Sep 1, 2014)  
Is option D correctly justified? As far as I know there is no such method void run(int priority) in Runnable interface. So I think explanation of option C and D must be same.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.