class X {
    protected int xMask = 0x00ff;
    protected int fullMask;

    public X() {
	System.out.println("X field initialization\t" +
	    Integer.toHexString(xMask) + "\t" +
	    Integer.toHexString(((Y)this).yMask) + "\t" +
	    Integer.toHexString(fullMask));
	fullMask = xMask;
	mask(0xffff);
	System.out.println("X constructor executed\t" +
	    Integer.toHexString(xMask) + "\t" +
	    Integer.toHexString(((Y)this).yMask) + "\t" +
	    Integer.toHexString(fullMask));
    }

    public int mask(int orig) {
	System.out.println("[X.mask() invocation: using fullMask == " +
	    Integer.toHexString(fullMask) + "]");
	return (orig & fullMask);
    }
}


class Y extends X {
    protected int yMask = 0xff00;

    public Y() {
	System.out.println("Y field initialization\t" +
	    Integer.toHexString(xMask) + "\t" +
	    Integer.toHexString(yMask) + "\t" +
	    Integer.toHexString(fullMask));
	fullMask |= yMask;
	System.out.println("Y constructor executed\t" +
	    Integer.toHexString(xMask) + "\t" +
	    Integer.toHexString(yMask) + "\t" +
	    Integer.toHexString(fullMask));
    }

    public static void main(String[] args) {
	System.out.println("\t\t\txMask\tyMask\tfullMask");
	Y y = new Y();
	y.mask(0xffff);
    }
}


Executing the class Y produces the following output:

				xMask	yMask	fullMask
	X field initialization	ff	0	0
	[X.mask() invocation: using fullMask == ff]
	X constructor executed	ff	0	ff
	Y field initialization	ff	ff00	ff
	Y constructor executed	ff	ff00	ffff
	[X.mask() invocation: using fullMask == ffff]


Using this version of Y instead, with an overriden mask() method:

class Y extends X {
    protected int yMask = 0xff00;

    public Y() {
	System.out.println("Y field initialization\t" +
	    Integer.toHexString(xMask) + "\t" +
	    Integer.toHexString(yMask) + "\t" +
	    Integer.toHexString(fullMask));
	fullMask |= yMask;
	System.out.println("Y constructor executed\t" +
	    Integer.toHexString(xMask) + "\t" +
	    Integer.toHexString(yMask) + "\t" +
	    Integer.toHexString(fullMask));
    }

    public int mask(int orig) {
	System.out.println("[Y.mask() invocation: using yMask == " +
	    Integer.toHexString(yMask) + "]");
	return (orig & yMask);
    }

    public static void main(String[] args) {
	System.out.println("\t\t\txMask\tyMask\tfullMask");
	Y y = new Y();
	y.mask(0xffff);
    }
}


produces this output:

				xMask	yMask	fullMask
	X field initialization	ff	0	0
	[Y.mask() invocation: using yMask == 0]
	X constructor executed	ff	0	ff
	Y field initialization	ff	ff00	ff
	Y constructor executed	ff	ff00	ffff
	[Y.mask() invocation: using yMask == ff00]
