Question: Multiselect. Given: class Animal { void makeSound ( ) { System.out.println ( Animal makes a sound ) ; } } class Dog extends Animal
Multiselect. Given:
class Animal
void makeSound
System.out.printlnAnimal makes a sound";
class Dog extends Animal
void makeSound
System.out.printlnDog barks";
class Cat extends Animal
void makeSound
System.out.printlnCat meows";
Which of the following statements about the code snippet are correct? Select all that apply
Question options:
An object of the Dog class can invoke the makeSound method defined in the Animal class.
An object of the Cat class cannot override the makeSound method.
Polymorphism allows a variable of type Animal to reference an object of type Dog or Cat.
The Animal class cannot have a makeSound method; it should be declared in subclasses only.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
