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:

Verified
Correct Answer:
Verified
Q11: Java allows one to create polymorphic references
Q21: What is printed by this code?<br><br> public class
Q22: Which statement is completely True?<br>A) Java upcasts
Q23: Consider the code shown below. It contains
Q25: We compare sorting algorithms by examining<br>A) the
Q29: Which of the following GUI components would
Q31: An interface reference can refer to any
Q31: Which of these methods will sort an
Q39: An int array stores the following values.
Q46: An int array stores the following values.