Questions
Question 1 Multiple Choice (Single Answer)
Which is true about an anonymous inner class?
- It can extend exactly one class and implement exactly one interface.
- It can extend exactly one class and can implement multiple interfaces.
- It can extend exactly one class or implement exactly one interface.
- It can implement multiple interfaces regardless of whether it also extends a class.
Question 2 Multiple Choice (Single Answer)
Which is true about a method-local inner class?
- It must be marked final.
- It can be marked abstract.
- It can be marked public.
- It can be marked static.
Question 3 Multiple Choice (Single Answer)
Which statement is true about a static nested class?
- You must have a reference to an instance of the enclosing class in order to instantiate it.
- It does not have access to nonstatic members of the enclosing class.
- It's variables and methods must be static.
- It must extend the enclosing class.
Question 4 Multiple Choice (Single Answer)
Which constructs an anonymous inner class instance?
- Runnable r = new Runnable() { };
- Runnable r = new Runnable(public void run() { });
- Runnable r = new Runnable { public void run(){}};
- System.out.println(new Runnable() {public void run() { }});