class
A
{
public int Avar;
public A() {
System.out.println("AAA");
doSomeThing();
}
public void doSomeThing() {
Avar = 1111;
System.out.println("A.doSomeThing()");
}
}
public class B extends A {
public int Bvar = 2222;
public B () {
System.out.println("BBB");
doSomeThing();
System.out.println("Avar=" + Avar);
}
public void doSomeThing(){
System.out.println("Bvar=" + Bvar);
}
public static void main(String[] args) {
new B();
}
}
public int Avar;
public A() {
System.out.println("AAA");
doSomeThing();
}
public void doSomeThing() {
Avar = 1111;
System.out.println("A.doSomeThing()");
}
}
public class B extends A {
public int Bvar = 2222;
public B () {
System.out.println("BBB");
doSomeThing();
System.out.println("Avar=" + Avar);
}
public void doSomeThing(){
System.out.println("Bvar=" + Bvar);
}
public static void main(String[] args) {
new B();
}
}
output is :
AAA
Bvar=0
BBB
Bvar=2222
Avar=0