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:

Self-Identification

The process by which an individual defines themselves based on their own perceptions and beliefs about their identity.

Emotional Engagement

The emotional connection a consumer has with a brand, characterized by feelings of loyalty and attachment, often the result of meaningful interactions.

Cultural Competence

The ability to understand, appreciate, and interact effectively with people of different cultures.

Node

A point in a network or system where connections are made, often used to refer to a basic unit within a data structure or a point of intersection in transport or communications networks.

Related Questions