Multiple choice

Which one create an anonymous inner class from within class Bar?

  1. Boo f = new Boo(24) { };

  2. Boo f = new Bar() { };

  3. Bar f = new Boo(String s) { };

  4. Boo f = new Boo.Bar(String s) { };

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

An anonymous inner class is created by extending a class or implementing an interface. Option B creates an anonymous subclass of Bar.