0

Java inner classes Quiz

Description: Java inner classes Quiz
Number of Questions: 4
Created by:
Tags: java
Attempted 0/4 Correct 0 Score 0
  1. It can extend exactly one class and implement exactly one interface.

  2. It can extend exactly one class and can implement multiple interfaces.

  3. It can extend exactly one class or implement exactly one interface.

  4. It can implement multiple interfaces regardless of whether it also extends a class.


Correct Option: C

Which is true about a method-local inner class?

  1. It must be marked final.

  2. It can be marked abstract.

  3. It can be marked public.

  4. It can be marked static.


Correct Option: B
  1. You must have a reference to an instance of the enclosing class in order to instantiate it.

  2. It does not have access to nonstatic members of the enclosing class.

  3. It's variables and methods must be static.

  4. It must extend the enclosing class.


Correct Option: B

Which constructs an anonymous inner class instance?

  1. Runnable r = new Runnable() { };

  2. Runnable r = new Runnable(public void run() { });

  3. Runnable r = new Runnable { public void run(){}};

  4. System.out.println(new Runnable() {public void run() { }});


Correct Option: D
- Hide questions