Constructs an anonymous inner class instance - Java
Q. Which constructs an anonymous inner class instance? (Java)- Published on 26 Jun 15a. Runnable r = new Runnable() { };
b. Runnable r = new Runnable(public void run() { });
c. Runnable r = new Runnable { public void run(){}};
d. System.out.println(new Runnable() {public void run() { }})
ANSWER: System.out.println(new Runnable() {public void run() { }})
The anonymous classes enables to make the code more concise. It enables to declare and instantiate a class at the same time. They are like local classes but they do not have a name.