adplus-dvertising
frame-decoration

Question

Which statement, inserted at line 10, creates an instance of Bar?
class Foo 
{
    class Bar{ }
}
class Test 
{
    public static void main (String [] args) 
    {
        Foo f = new Foo();
        /* Line 10: Missing statement ? */
    }
}

a.

Foo.Bar b = new Foo.Bar();

b.

Foo.Bar b = f.new Bar();

c.

Bar b = new f.Bar();

d.

Bar b = f.new Bar();

Posted under Java Programming

Answer: (b).Foo.Bar b = f.new Bar();

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which statement, inserted at line 10, creates an instance of Bar?