Hi everyone.I got a question from Marcus Green'a mock 1
Question 34)
Which of the following statements about this code are true?
public class Morecombe{
public static void main(
String argv[]){
Morecombe m = new Morecombe();
m.go(new Turing(){});
}
public void go(Turing t){
t.start();
}
}
class Turing extends Thread{
public void run(){
for(int i =0; i < 2; i++){
System.out.println(i);
}
}
}
1) Compilation error due to malformed parameter to go method
2) Compilation error, class Turing has no start method
3) Compilation and output of 0 followed by 1
4) Compilation but runtime error
its seemed that line 4 ,
m.go(new Turing(){});
make a anonymous class "Turing(){}",i thought it different from the below one .But after i took the "{}" away,its still works well.
Dos "{}"has nothing to do with it?