Examlex

Solved

What Is Printed? Public Class Inherit

question 6

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 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( ) ;
}
}


Definitions:

Weathered Rock

Rock that has been changed physically or chemically by the action of weather, water, or biological organisms.

Precipitation

Any form of water - liquid or solid - falling from the sky, including rain, snow, sleet, and hail.

Karst

A landscape formed from the dissolution of soluble rocks such as limestone, characterized by sinkholes, caves, and underground rivers.

Iron and Aluminum

Essential metals abundant in the Earth's crust, often forming various minerals and playing crucial roles in industrial applications.

Related Questions