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 Quizplus AI
Q33: Which of these methods will sort an
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
Q39: 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
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