Examlex

Solved

What Is Printed by This Code

question 21

Multiple Choice

What is printed by this code?

public class Inherit
{

class Figure
{
void display( )
{
System.out.println("Figure") ;
}
}

class Rectangle extends Figure
{
void display( )
{
System.out.println("Rectangle") ;
}
void display(String s)
{
System.out.println(s) ;
}
}

class Box extends Figure
{
void display( )
{
System.out.println("Box") ;
}
void display(String s)
{
System.out.println("This is printed: " + s) ;
}
}

Inherit( )
{
Figure f = new Figure( ) ;
Rectangle r = new Rectangle( ) ;
Box b = new Box( ) ;
f.display( ) ;
f = r;
f.display("one") ;
f = b;
f.display("two") ;
}

public static void main(String[ ] args)
{
new Inherit( ) ;
}
}


Definitions:

Agenda

A list or plan of items to be discussed or acted upon in a meeting or gathering.

List Of Objectives

An itemized collection of goals or targets aimed to be achieved within a specified timeframe.

Meeting

A gathering of people for the purpose of discussing and acting upon business or other shared interests.

Minutes

A report of what happened and what was discussed and decided at a meeting.

Related Questions