Virajsinh

Java_14

Feb 15th, 2018
53
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Write a Java Program To Explain The Concept of Various Inheritance
  2. //2. MultiLevel Inheritance
  3.  
  4. class Animal
  5. {
  6.     void eat()
  7.     {
  8.         System.out.println("Eating");
  9.     }
  10. }
  11.  
  12. class Dog extends Animal
  13. {
  14.     void bark()
  15.     {
  16.         System.out.println("Barking");
  17.     }
  18. }
  19.  
  20. class BabyDog extends Dog
  21. {
  22.     void cry()
  23.     {
  24.         System.out.println("Baby Dog is Crying");
  25.     }
  26.    
  27. }
  28.  
  29. class Ex14 // Ex14 is FileName
  30. {
  31.     public static void main(String args[])
  32.     {
  33.         BabyDog b = new BabyDog();
  34.         b.bark();
  35.         b.eat();
  36.         b.cry();
  37.     }
  38. }
RAW Paste Data