Solved

What Is Printed? Public Class Inherit

Question 34

Multiple Choice

What is printed?

public class Inherit
{

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

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

void tryme(Figure f)
{
f.display( ) ;
}

Inherit( )
{
Figure f = new Line( ) ;
tryme(f) ;
}

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


A) Line
B) Figure
C) Shape
D) Syntax error; the code won't even compile
E) none of the above

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents