Given the code below:
public class Color extends
Thread {
public static void main(
String [] args){
new Color(new MyRunnable()).start();
}
public void run(){
System.out.println("Color run");
}
public Color(Runnable runnable){
super(runnable);
}
}
class MyRunnable implements Runnable{
public void run(){
System.out.println("MyRunnable run");
}
}
And the posibilities:
A. Compilation fails
B. Runtime Exception
C. Color run
D. MyRunnable Run
The answer is C (I tried it and it's really C). But what I do not understand is: "the Target" is MyRunnable how come it's run method is not getting called? What am i missing here(again that is
)
thank you,
Eugene.