Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. class AA
  2. {
  3. int i=10;
  4. void method()
  5. {
  6. System.out.println("AA "+i);
  7. }
  8. }
  9. class BB extends AA
  10. {
  11. int i = 20;
  12. void method()
  13. {
  14. AA a = new BB();
  15. System.out.println("BB "+a.i);
  16. }
  17. }
  18. public class MainClass
  19. {
  20. public static void main(String[] args)
  21. {
  22. AA a = new BB();
  23. BB b = new BB();
  24. a.method();
  25. b.method();
  26. System.out.println(a.i);
  27. System.out.println(b.i);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement