Java-Reference variable: super




class TestSuperFunc {
public static void main(String[] args) {
SubClass sub = new SubClass(10, 20, 30);
}
}

class SuperClass {
private int x = 0;
private int y = 0;

SuperClass() {
}
SuperClass(int value) {
x = value;
y = value;
}
SuperClass(int x, int y) {
this.x = x;
this.y = y;
}
}
class SubClass extends SuperClass {
private int z = 0;

SubClass() {
}
SubClass(int value) {
super(value);
z = value;
}
SubClass(int x, int y, int z) {
super(x, y);
this.z = z;
}
}


Post a Comment

0 Comments