Java OCA OCP Practice Question 1112

Question

What is the output of the following program?

class Question extends SuperClass {
   String s = "this";

   public static void main(String[] args) {
      new Question();
   }/*from w w w.  j a va 2 s  .  c om*/

   Question() {
      super.display(s);
   }

   void display(String s) {
      System.out.println("this: " + s);
   }
}

class SuperClass {
   String s = "super";

   void display(String s) {
      System.out.println("super: " + s);
   }
}
  • A. this: this
  • B. super: this
  • C. this: super
  • D. super: super


B.

Note

The display() method of SuperClass is invoked to display the s variable of Question.




PreviousNext

Related