Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main2 {
- static class A {
- String str = "abc";
- public A() {
- System.out.print("Class A constructor str = " + str);
- print();
- }
- void print() {
- System.out.println(str.length());
- }
- }
- static class B extends A {
- String str = "ab";
- public B() {
- System.out.println(str.length());
- System.out.print("Class B constructor str = " + str);
- print();
- }
- @Override
- void print() {
- //System.out.println(str.length());
- System.out.println(str);
- }
- }
- public static void main(String[] args) {
- new B();
- }
- }
Add Comment
Please, Sign In to add comment