Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started