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
Q2: It is possible to sort an array
Q9: A polymorphic reference can refer to different
Q29: What is the efficiency of binary search?
A)
Q30: Considering the event processing classes, what is
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
Q37: What is printed?
public class Inherit
{
abstract class
Q53: To swap the 3ʳᵈ and 4ᵗʰ elements
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