Solved

What Is Printed by the Following Code

Question 69

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