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 1)

Java Other Question

_____ exceptions are automatically propagated. To propogate _____ exceptions, the method should explicitly throw the exception using the throws keyword.

A. checked, unchecked
B. unchecked, checked
6. Which of the following refers to data encapsulation in object oriented programming?

A. The data and operations for an object are defined and fixed

B. The data of an object is encapsulated in its class

C. The data is hidden for an object

D.A class can have multiple object​