Virajsinh

Java_13

Feb 15th, 2018
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. //Write a Java Program TO Explain The Concept of Various Inheritance
  2. //1. Single 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 Ex13 // Ex13 is FileName
  21. {
  22.     public static void main(String args[])
  23.     {
  24.         Dog d = new Dog();
  25.         d.bark();
  26.         d.eat();
  27.     }
  28. }
Add Comment
Please, Sign In to add comment