Hi All
there are few questions from Khaalid Mock Exam
Since answers are not provided I would be thnakful if you give your views
Given that a static method doIt() in a class Work represents work to be done, what block of code will succeed in starting a new
thread that will do the work?
CODE BLOCK A:
Runnable r = new Runnable() {
public void run() {
Work.doIt();
}
};
Thread t = new Thread(r);
t.start();
CODE BLOCK B:
Thread t = new Thread() {
public void start() {
Work.doIt();
}
};
t.start();
CODE BLOCK C:
Runnable r = new Runnable() {
public void run() {
Work.doIt();
}
};
r.start();
CODE BLOCK D:
Thread t = new Thread(new Work());
t.start();
CODE BLOCK E:
Runnable t = new Runnable() {
public void run() {
Work.doIt();
}
};
t.run();
a.Code block A
b.Code block B
c.Code block C
d.Code block D
e.Code block E
Only b is correct according to me as we cannot instaniate an Interface
what fo you all say ?