Question: abstract class Animal { abstract void makeSound ( ) ; void sleep ( ) { System.out.println ( Zzz ) ; } } class

abstract class Animal {
abstract void makeSound();
void sleep(){
System.out.println("Zzz");
}
}
class Dog extends Animal {
@Override
void makeSound(){
System.out.println("Woof");
}
}
public class Main {
public static void main(String[] args){
Animal dog = new Dog();
dog.makeSound();
dog.sleep();
}
}What will be the output when the above code is executed?
1 point
Compilation error due to not implementing the abstract method makeSound() in the Dog class
Woof
Zzz
Compilation error due to attempting to create an instance of an abstract class.
Compilation error due to attempting to access the private method sleep() in the Animal class
7.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!