Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. Class Animal
  2. {
  3.  
  4. public void eat()
  5. {
  6. System.out.println("Animal Eating");
  7. }
  8. }
  9.  
  10. Class Dog extends Animal
  11. {
  12.  
  13. public void eat()
  14. {
  15. System.out.println("Dog is eating);
  16. }
  17.  
  18. }
  19.  
  20. class Bindingtest
  21. {
  22. public static void main(String[] args)
  23. {
  24. Animal a = new Animal();
  25. a.eat(); // Prints Animal eating
  26. Animal a1 = new Dog();
  27. a1.eat(); // Prints Dog eating
  28. }
  29. }
  30.  
  31. Here my my doubt is , in below both cases,that is
  32. 1) a.eat(); // Prints Animal eating ---> Static Binding
  33. 2) a1.eat(); // Prints Dog eating ----> Dynamic Binding
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement