Accenture Accenture Primer Practice Question
class mammel{ String name= "Dog"; String makenoise(){Answer options
A
return "Bow Wow";
B
class Cat extends mammel{
C
String name="Cat";
D
String makeNoise()
E
return "Meow";
F
public class Main{
G
public static void main (String[] args) {
H
new Main.go();
I
void go()
J
mammel m=new Cat();
Correct answer: mammel m=new Cat();
Explanation
mammel m = new Cat() — polymorphism applies to methods, not fields. m.makeNoise() calls Cat's overridden method ('Meow'). m.name accesses mammel's field ('Dog'). Output: 'Dog Meow'. Option 9 (mammel m=new Cat()) represents the polymorphic assignment that drives this behavior.