This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Runnable interface question from Marcus tutorial Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Runnable interface question from Marcus tutorial" Watch "Runnable interface question from Marcus tutorial" New topic
Author

Runnable interface question from Marcus tutorial

Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Here is a question from Marcus Thread tutorial:
What will happen when you attempt to compile and run this code?
public class Runt implements Runnable{
public static void main(String argv[]){
Runt r = new Runt();
Thread t = new Thread(r);
t.start();
}
public void start(){
for(int i=0;i<100;i++)
System.out.println(i);
}
}
1) Compilation and output of count from 0 to 99
2) Compilation and no output
3) Compile time error: class Runt is an abstract class. It can't be instantiated.
4) Compile time error, method start cannot be called directly
----------------------------------------------------

The answer is 3. Runt is not defined as abstract class. So the error should be that Run method of Runnable interface is not implemented in Runt or Runt is not defined as abstract.....right?
Thanks
Barkat
[ June 09, 2003: Message edited by: Barkat Mardhani ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Try it and see what compiler error message you get.
Bill
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
Hi Barkat
Yes a problem of wording.
 
Don't get me started about those stupid light bulbs.
 
subject: Runnable interface question from Marcus tutorial