Welcome Guest | Sign in | Register
Declarations and Access Control - Discussion Page For Q.2594 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Exercise:

Section 1

Q: Which two statements are true for any concrete class implementing the java.lang.Runnable interface?
1. You can extend the Runnable interface as long as you override the public run ( ) method.
2. The class must contain a method called run ( ) from which all code for that thread will be initiated.
3. The class must contain an empty public void method named run ( ).
4. The class must contain a public void method named runnable ( ).
5. The class definition must include the words implements Threads and contain a method called run ( ).
6. The mandatory method must be public, with a return type of void, must be called run ( ), and cannot take any arguments.
A. 1 and 3 B. 2 and 4
C. 1 and 5 D. 2 and 6

Answer and Explanation

Answer:2 and 6

Explanation:
(2) and (6). When a thread's run ( ) method completes, the thread will die. The run ( ) method must be declared public void and not take any arguments.
(1) is incorrect because classes can never extend interfaces. (3) is incorrect because the run ( ) method is typically not empty; if it were, the thread would do nothing. (4) is incorrect because the mandatory method is run ( ). (5) is incorrect because the class implements Runnable.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.