Java OCA OCP Practice Question 885

Question

What is the output of the following program?

public class Main {
   String s = "Outer";

   public static void main(String[] args) {
      new Main().new Inner();
   }//w w  w.j  a v a2s  .  c  om

   Main() {
      System.out.print(s);
   }

   class Inner {
      String s = "Inner";

      Inner() {
         System.out.print(s);
      }
   }

}
A.   Outer   
B.   Inner   
C.   OuterInner   
D.   InnerOuter   


C

Note

An instance of Outer is created, followed by an instance of Inner.




PreviousNext

Related