Guest User

Untitled

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