Solved

What Is Printed? Public Class Inherit

Question 2

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

Related Questions