Solved

What Is Printed

Question 37

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

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents