Java
Programming and Technical
Programming
Output
class Mammal
{
String name= "Dog";
String makeNoise()
{
return "Bow Wow";
}
}
class Cat extends Mammal
{
String name="Cat";
String makeNoise()
{
return "Meow";
}
}
public class Main
{
void go()
{
Mammal m = new Cat();
System.out.println(m.name + m.makeNoise());
}
public static void main (String[] args)
{
new Main().go();
}
}
What is the output of the above program?
A. CatMeow
B. DogBow Wow
C. DogMeow
D. CatBow Wow
Read Solution (Total 2)
-
- A. CatMeow
- 2 years agoHelpfull: Yes(0) No(0)
- A. CatMeow
- 2 Months agoHelpfull: Yes(0) No(0)
Java Other Question