What is printed?
public class Inherit
{
abstract class Figure
{
void display( )
{
System.out.println("Figure") ;
}
}
abstract class Rectangle extends Figure
{
}
class Box extends Rectangle
{
void display( )
{
System.out.println("Rectangle") ;
}
}
Inherit( )
{
Figure f = (Figure) new Box( ) ;
f.display( ) ;
Rectangle r = (Rectangle) f;
r.display( ) ;
}
public static void main(String[ ] args)
{
new Inherit( ) ;
}
}
A) Rectangle
Rectangle
B) Rectangle
Figure
C) Figure
Rectangle
D) Figure
Figure
E) none of the above
Correct Answer:
Verified
Q32: What is printed by the following code?
public
Q33: Which of these methods will sort an
Q34: What is printed?
public class Inherit
{
abstract class Figure
{
void
Q35: Although insertion sort and selection sort have
Q36: Which statement is completely True?
A) Java upcasts
Q38: What is printed?
public class Inherit
{
class Figure
{
void
Q39: What is printed?
public class Inherit
{
class Figure
{
void
Q40: "class Aggregate" is incorrect. Choose the correct
Q41: Choosers-like file choosers and color choosers-provide a
Q42: A class reference can refer to any
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents