Guest User

Untitled

a guest
Aug 30th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. class A {
  2. A getThis() {System.out.println("call getThis() from A"); return this;} //(3)
  3. Object getSuper() {System.out.println("call getSuper() from A"); return null;}
  4. }
  5.  
  6. class B extends A {
  7. B getThis() {System.out.println("call getThis() from B"); return this;}
  8. A getSuper() {System.out.println("call getSuper() from B"); return super.getThis();}
  9. }
  10.  
  11. class Tester {
  12. public static void main (String[] args) {
  13. Object a = new B().getSuper(); //(1)
  14. System.out.println(a);
  15. a = new B().getSuper().getSuper(); //(2)
  16. System.out.println(a);
  17. }
  18. }
  19.  
  20. static class A {
  21. A getThis() {System.out.println("call getThis() from A"); return this;} //(3)
  22. Object getSuper() {System.out.println("call getSuper() from A"); return null;}
  23. }
  24.  
  25. static class B extends A {
  26. B getThis() {System.out.println("call getThis() from B"); return this;}
  27. A getSuper() {System.out.println("call getSuper() from B"); return super.getThis();}
  28. }
Add Comment
Please, Sign In to add comment