Cycle 02
Lab Cycle 2 — OOP Concepts
Inheritance
Problem Statement
Write a Java program to demonstrate inheritance with super keyword.
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