1

What will be the output of the following Java program? class A { int i; public void display() { System.out.println(i); } } class B extends A { int j; public void display() { System.out.println(j); } } class Dynamic_dispatch { public static void main(String args[]) { B obj2 = new B(); obj2.i = 1; obj2.j = 2; A r; r = obj2; r.display(); } }

Correct Answer: 2

Make the most of this question

This page focuses on one JAVA MCQs question from Programming. After checking the answer, return to the topic list to practice more or run a timed set.