× Didn't find what you were looking for? Ask a question
Top Posters
Since Sunday
5
a
5
k
5
c
5
B
5
l
5
C
4
s
4
a
4
t
4
i
4
r
4
New Topic  
DePeet DePeet
wrote...
Posts: 338
Rep: 0 0
5 years ago
What is the output of 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 these
Read 54 times
1 Reply
Replies
Answer verified by a subject expert
StingerStinger
wrote...
Posts: 310
Rep: 4 0
5 years ago
Sign in or Sign up in seconds to unlock everything for free
1

Related Topics

DePeet Author
wrote...

5 years ago
Thank you, thank you, thank you!
wrote...

Yesterday
Helped a lot
wrote...

2 hours ago
Correct Slight Smile TY
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1330 People Browsing
Related Images
  
 422
  
 378
  
 342
Your Opinion
Who will win the 2024 president election?
Votes: 3
Closes: November 4

Previous poll results: Do you believe in global warming?