Java
Programming and Technical
Verbal Ability
Miscellaneous
Which constructs an anonymous inner class instance?
A. 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() { }});
Read Solution (Total 5)
-
- D is correct. It defines an anonymous inner class instance, which also means it creates an instance of that new anonymous class at the same time. The anonymous class is an implementer of the Runnable interface, so it must override the run() method of Runnable.
- 8 years agoHelpfull: Yes(2) No(0)
- Ans -D.... bcoz anonymous class is the class which name is not defined bt its object is created and implementation is also given
- 8 years agoHelpfull: Yes(2) No(0)
- option D
- 9 years agoHelpfull: Yes(1) No(0)
- option c - Runnable r = new Runnable { public void run(){}};
- 9 years agoHelpfull: Yes(0) No(1)
- Answer is option d because anonymous inner class means class without a name.
- 6 years agoHelpfull: Yes(0) No(0)
Java Other Question