Question 03 of 05

Inheritance

Write a Java program to demonstrate inheritance with super keyword.

C++
class Animal {
    void eat() { System.out.println("Animal eats"); }
}
class Dog extends Animal {
    void bark() { System.out.println("Dog barks"); }
}
public class Main {
    public static void main(String[] args) {
        Dog d = new Dog();
        d.eat();
        d.bark();
    }
}
Question 3 of 5