Multiple Choice
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 Figure
{
void display( )
{
System.out.println("Box") ;
}
}
Inherit( )
{
Figure f = new Figure( ) ;
Rectangle r = new Rectangle( ) ;
Box b = new Box( ) ;
f.display( ) ;
f = r;
f.display( ) ;
f = b;
f.display( ) ;
}
public static void main(String[ ] args)
{
new Inherit( ) ;
}
}
A) Figure
Rectangle
Box
B) Rectangle
Box
C) Figure
Figure
Figure
D) Syntax error; this code won't compile or execute
E) none of the above
Correct Answer:

Answered by ExamLex AI
Correct Answer:
Answered by ExamLex AI
Q5: Polymorphism is achieved by<br>A) overloading<br>B) overriding<br>C) embedding<br>D)
Q17: The fact that the System.out.println() method is
Q20: An int array stores the following values.
Q21: A polymorphic reference can refer to different
Q55: Can a program exhibit polymorphism if it
Q58: Write the code needed to set up
Q59: A JSlider, xSlider, is used to change
Q61: Which of the following GUI components would
Q62: Which of the following is a listener
Q63: Why is it almost always a good