Advertisement
thenewboston

Java Programming Tutorial - 49 - Inheritance

Aug 22nd, 2014
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. public class apples {
  2.    public static void main(String[] args){
  3.       tuna tunaObject = new tuna();
  4.       potpie potObject = new potpie();
  5.      
  6.       tunaObject.eat();
  7.       potObject.eat();
  8.      
  9.    }
  10. }
  11.  
  12. public class tuna extends food {
  13.    public void eat(){
  14.       System.out.println("I am the new method of tuna");      
  15.    }
  16. }
  17.  
  18. public class potpie extends food{
  19.  
  20. }
  21.  
  22. public class food {
  23.    public void eat(){
  24.       System.out.println("I am the eat methods");      
  25.    }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement