Java OCA OCP Practice Question 3248

Question

Consider the following program:

class Outer {//  w  w  w.j a v  a 2 s  .co  m
     class Inner {
             public void print() {
                    System.out.println("Inner: print");
             }
     }
}

class Test {
     public static void main(String []args) {
             // Stmt#1
             inner.print();
     }
}

Which one of the following statements will you replace in place of //Stmt#1 to make the program compile and run successfully to print "Inner: print" in console?

  • a) Outer.Inner inner = new Outer.Inner();
  • b) Inner inner = new Outer.Inner();
  • c) Outer.Inner inner = new Outer().Inner();
  • d) Outer.Inner inner = new Outer().new Inner();


d)



PreviousNext

Related