Guest User

Untitled

a guest
Jul 20th, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public class Main2 {
  2.  
  3. static class A {
  4. String str = "abc";
  5.  
  6. public A() {
  7. System.out.print("Class A constructor str = " + str);
  8. print();
  9. }
  10.  
  11. void print() {
  12. System.out.println(str.length());
  13. }
  14. }
  15.  
  16. static class B extends A {
  17. String str = "ab";
  18.  
  19. public B() {
  20. System.out.println(str.length());
  21. System.out.print("Class B constructor str = " + str);
  22. print();
  23. }
  24.  
  25. @Override
  26. void print() {
  27. //System.out.println(str.length());
  28. System.out.println(str);
  29. }
  30. }
  31.  
  32. public static void main(String[] args) {
  33. new B();
  34. }
  35. }
Add Comment
Please, Sign In to add comment