Question: 2 . What will the following Java code output? / / Example 2 class Parent { public void display ( ) { System.out.println (
What will the following Java code output?
Example
class Parent
public void display
System.out.printlnParent class method";
class Child extends Parent
@Override
public void display
System.out.printlnChild class method";
public class Main
public static void mainString args
Parent obj;
if argslength
obj new Child;
else
obj new Parent;
obj.display;
B Child class method
D Runtime Error
C Compilation Error
A Parent class method
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
