Which of the following creates an instance of an anonymous inner class?
A. new Runnable();
B. new Runnable(public void run());
C. new Runnable r = public void run();
D. System.out.println(new Runnable() public void run());
Answer:D
Which of the following creates an instance of an anonymous inner class?
A. new Runnable(); B. new Runnable(public void run()); C. new Runnable r = public void run(); D. System.out.println(new Runnable() public void run());
Explanation: It declares an anonymous inner class instance, which implies that it also generates an instance of that new anonymous class at the same time. Because the anonymous class implements the Runnable interface, it must override the Runnable interface's run() method.A is improper because it does not override the run() method, which violates the norms of intepretation.