Question: What will be displayed when the following code executes? class One { void display ( ) { System.out.println ( One ) ; }
What will be displayed when the following code executes?
class One
void display
System.out.println One;
class Two extends One
void display
System.out.println Two;
public class Main
public static void main Stringargs
One obj new One ;
Two obj new Two ;
One obj new Two ;
One obj obj;
objdisplay ;
objdisplay ;
objdisplay ;
objdisplay ;
One Two One Two
One Two One One
One Two Two Two
One Two Two OneWhat will be displayed when the following code executes?
class One
void display
System.out.println One;
class Two extends One
void display
System.out.println Two;
public class Main
public static void main Stringargs
One obj new One ;
Two obj new Two ;
One obj new Two ;
One obj obj;
objdisplay ;
objdisplay ;
objdisplay ;
objdisplay ;
One Two One Two
One Two One One
One Two Two Two
One Two Two One
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
