I don't want to call z = x + y in every subclass of SuperClass.
Just give z a default value in your superclass then, e.g. x+y, or leave it blank if you wish. Then in the subclass, define z as you want in the constructor.
public class SuperClass{
int x, y, z;
SuperClass(int x, int y){
this.x = x;
this.y = y;
//pick a default value of z;
z = x + y;
}
}
public class Example extends SuperClass {
Example(int x, int y){
super(x , y);
//pick another z implementation here;
z = x * y ^ x;
}
}