This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 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: 12682
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Runnable interface question from Marcus tutorial
 
Similar Threads
Thread doubt?
Marcus Green: incorrect answer?
Threads: question from jchq
is this Ambiguous?
java