What is printed?
public class Inherit
{
class Figure
{
void display( )
{
System.out.println("Figure") ;
}
}
class Rectangle extends Figure
{
void display( )
{
System.out.println("Rectangle") ;
}
}
class Box extends Rectangle
{
void display( )
{
System.out.println("Box") ;
}
}
Inherit( )
{
Figure f = new Figure( ) ;
Rectangle r = new Rectangle( ) ;
Box b = new Box( ) ;
f.display( ) ;
f = r;
((Figure) f) .display( ) ;
f = (Figure) b;
f.display( ) ;
}
public static void main(String[ ] args)
{
new Inherit( ) ;
}
}
A) Figure
Rectangle
Box
B) Figure
Figure
Figure
C) Figure
Rectangle
Figure
D) Rectangle
Figure
E) none of the above
Correct Answer:
Verified
Q34: What is printed?
public class Inherit
{
abstract class Figure
{
void
Q35: Although insertion sort and selection sort have
Q36: Which statement is completely True?
A) Java upcasts
Q37: What is printed?
public class Inherit
{
abstract class
Q38: What is printed?
public class Inherit
{
class Figure
{
void
Q40: "class Aggregate" is incorrect. Choose the correct
Q41: Choosers-like file choosers and color choosers-provide a
Q41: Demonstrate how the following array is sorted
Q42: A class reference can refer to any
Q44: Binary search can be used on unsorted
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents