Solved

What Is Printed by the Following Code

Question 32

Multiple Choice

What is printed by the following code?
public class Inherit
{

abstract class Speaker
{
abstract public void speak( ) ;
}
class Cat extends Speaker
{
public void speak( )
{
System.out.println("Woof!") ;
}
}

class Dog extends Speaker
{
public void speak( )
{
System.out.println("Meow!") ;
}
}

Inherit( )
{
Speaker d = new Dog( ) ;
Speaker c = new Cat( ) ;
d.speak( ) ;
c.speak( ) ;
}

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


A) Woof!
Meow!
B) Meow!
Woof!
C) Meow!
Meow!
D) Woof!
Woof!
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