To solve this question, the user needs to have knowledge of Java threads, Runnable interface, and the difference between extending and implementing a class/interface.
The code snippet above creates a Thread using a Runnable target. To use this code snippet, the user needs to create a class that implements the Runnable interface. The Runnable interface has only one method, which is the run() method.
Now, let's go through each option and explain why it is right or wrong:
A. public class MyRunnable extends Runnable{public void run(){}}
This option is incorrect because the Runnable interface cannot be extended. It can only be implemented.
B. public class MyRunnable extends Object{public void run(){}}
This option is incorrect because it does not implement the Runnable interface. Instead, it extends the Object class and defines a run() method, which is not the correct implementation of the run() method from the Runnable interface.
C. public class MyRunnable implements Runnable{public void run(){}}
This option is correct. It creates a class called MyRunnable that implements the Runnable interface. It defines the run() method, which is required by the Runnable interface. Therefore, this code will compile correctly.
D. public class MyRunnable implements Runnable{void run(){}}
This option is incorrect because the run() method is missing the public access modifier. The run() method must be declared as public since it is an implementation of the run() method from the Runnable interface.
Therefore, the correct answer is:
The Answer is: C