Guest User

Untitled

a guest
Feb 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. //polymorphism
  2.  
  3.  
  4. class Animal {
  5. int weight;
  6. int location;
  7. }
  8.  
  9.  
  10.  
  11. class Cat {
  12. int weight;
  13. int location;
  14. int clawlength;
  15. }
  16.  
  17.  
  18. Cat cat = new Cat();
  19. Animal animal = (Animal) cat;
  20.  
  21. //because the byteorders are the same for the two classes, you can "cast" between the two classes as if Cat inherited from Animal
Add Comment
Please, Sign In to add comment