Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runnable interface question from Marcus tutorial

 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try it and see what compiler error message you get.
Bill
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Barkat
Yes a problem of wording.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic