Question: a) A1B1C1 b) A1B1C1C2 c) Runtime Error d) Compilation Error What is the output of this code? class A { public void firstMethod() { System.out.print(A1);

a) A1B1C1 b) A1B1C1C2 c) Runtime Error d) Compilation Error
What is the output of this code? class A { public void firstMethod() { System.out.print("A1"); } } class B extends A{ public void firstMethodo { System.out.print("B1"); } } class C extends A{ public void firstMethod() { System.out.print("C1"); } public void second Method() { System.out.print("c2"); } } A[] aArr = new A[3]; Arr[0] = new AO: aArr[1] = new BO; aArr[2] = new CO: for (A obj: aArr) { obj.firstMethod(); if (obj instanceof C){ Cc= (C) obj; c.second Method(); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
