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:

Verified
Correct Answer:
Verified
Q5: Polymorphism is achieved by<br>A) overloading<br>B) overriding<br>C) embedding<br>D)
Q17: The fact that the System.out.println() method is
Q60: What is printed? <br><br> public class Inherit<br> {<br><br> class Figure<br> {<br> void
Q61: Which of the following GUI components would
Q62: Which of the following is a listener
Q63: Why is it almost always a good
Q66: The type of the reference, not the
Q67: What does the following code do? Assume
Q68: Comparing the performance of selection sort and
Q70: Although insertion sort and selection sort have