Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Write a Java Program To Explain The Concept of Various Inheritance
- //2. MultiLevel Inheritance
- class Animal
- {
- void eat()
- {
- System.out.println("Eating");
- }
- }
- class Dog extends Animal
- {
- void bark()
- {
- System.out.println("Barking");
- }
- }
- class BabyDog extends Dog
- {
- void cry()
- {
- System.out.println("Baby Dog is Crying");
- }
- }
- class Ex14 // Ex14 is FileName
- {
- public static void main(String args[])
- {
- BabyDog b = new BabyDog();
- b.bark();
- b.eat();
- b.cry();
- }
- }
Add Comment
Please, Sign In to add comment