Multiple choice technology programming languages

class Boo {
    Boo(String s) {}
    Boo() {}
}
class Bar extends Boo {
    Bar() {}
    Bar(String s) {
        super(s);
    }
    void zoo() { 
         // insert code here      
    }  
}

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

The correct syntax creates an anonymous subclass of Bar (which extends Boo). Option A is wrong because 24 is not a String. Option C is syntactically invalid. Option D is wrong syntax for anonymous class creation. Option B correctly instantiates Bar and makes it anonymous.