Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public class A {
  2.  
  3. void callme() {System.out.print("A");}
  4.  
  5. }
  6.  
  7. public class B extends A{
  8.  
  9. void callme() {System.out.print("B");}
  10.  
  11. }
  12.  
  13. public class C extends B{
  14.  
  15. void callme() {System.out.print("C");}
  16.  
  17. }
  18.  
  19. public class Extender {
  20.  
  21. public static void main(String[] args) {
  22.  
  23. A a = new A();
  24.  
  25. B b = new B();
  26.  
  27. C c = new C();
  28.  
  29. A r = a;
  30.  
  31. r.callme();
  32.  
  33. r = b;
  34.  
  35. r.callme();
  36.  
  37. r = c;
  38.  
  39. r.callme();
  40.  
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement