Can somebody please explain this question from Khalid Mughal Mock
test :
Q5. Given that a static method doIt() in the class Work represents work to be done, which block of code will succeed in starting a new
thread that will do the work?
a. Runnable r = new Runnable() {
public void run() {
Work.doIt();
}
};
Thread t = new Thread (r);
t.start();
b. Thread t = ne Thread () {
public void start() {
Work.doIt();
}
};
t.start();
c. Runnable r = new Runnable () {
public void run() {
Work.doIt();
}
};
r.start();
d. Thread t = new Thread (new Work());
t.start();
e. Runnable t = new Runnable () {
public void run() {
Work.doIt();
}
};
t.run();
Answer is a. Please explain how can an interface be instantiated like this and why other options are wrong.
Secondly on the MindQ test :
Q7. Represent the number 6 as a hexadecimal literal.
Answers are 0x6, 0x06, 0X6, 0X06
I wrote the answer as 0x0006. Is this wrong?