Q.1.

Which constructs an anonymous inner class instance?

Q.2.

class Foo 
{
    class Bar{ }
}
class Test 
{
    public static void main (String [] args) 
    {
        Foo f = new Foo();
        /* LineMissing statement ? */
    }
}
which statement, inserted at linecreates an instance of Bar?
Q.3.

public class MyOuter 
{
    public static class MyInner 
    {
        public static void foo() { }
    }
}
which statement, if placed in a class other than MyOuter or MyInner, instantiates an instance of the nested class?
Q.4.

Which is true about an anonymous inner class?

Q.5.

What will be the output of the program?

public class Foo 
{
    Foo() 
    {
        System.out.print("foo");
    }
    
class Bar
{
    Bar() 
    {
        System.out.print("bar");
    }
    public void go() 
    {
        System.out.print("hi");
    }
} /* class Bar ends */

    public static void main (String [] args) 
    {
        Foo f = new Foo();
        f.makeBar();
    }
    void makeBar() 
    {
        (new Bar() {}).go();
    }
}/* class Foo ends */
Q.6.

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?
Q.7.

What will be the output of the program?

public class HorseTest 
{
    public static void main (String [] args) 
    {
        class Horse 
        {
            public String name; /* Line 7 */
            public Horse(String s) 
            {
                name = s;
            }
        } /* class Horse ends */
        
        Object obj = new Horse("Zippo"); /* Line*/
        Horse h = (Horse) obj; /* Line*/
        System.out.println(h.name);
    }
} /* class HorseTest ends */
Q.8.

Which is true about a method-local inner class?

Q.9.

What will be the output of the program?

public class TestObj 
{
    public static void main (String [] args) 
    {
        Object o = new Object() /* Line 5 */
        {
            public boolean equals(Object obj) 
            {
                return true;
            } 
        }      /* Line*/
        
        System.out.println(o.equals("Fred"));
    }
}
Q.10.

Which statement is true about a static nested class?

Q.11.

What will be the output of the program?

public abstract class AbstractTest 
{
    public int getNum() 
    {
        return    }
    public abstract class Bar 
    {
        public int getNum() 
        {
            return        }
    }
    public static void main (String [] args) 
    {
        AbstractTest t = new AbstractTest() 
        {
            public int getNum() 
            {
                return            }
        };
        AbstractTest.Bar f = t.new Bar() 
        {
            public int getNum() 
            {
                return            }
        };
        
        System.out.println(f.getNum() + " " + t.getNum());
    }
}