Solved

What Is Printed

Question 26

Multiple Choice

What is printed?

public class Inherit
{

abstract class Figure
{
void display( )
{
System.out.println("Figure") ;
}
}

abstract class Rectangle extends Figure
{
}

class Box extends Rectangle
{
void display( )
{
System.out.println("Rectangle") ;
}
}

Inherit( )
{
Figure f = (Figure) new Box( ) ;
f.display( ) ;
Rectangle r = (Rectangle) f;
r.display( ) ;
}

public static void main(String[ ] args)
{
new Inherit( ) ;
}
}


A) Rectangle
Rectangle
B) Rectangle
Figure
C) Figure
Rectangle
D) Figure
Figure
E) none of the above

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions