This is one of Dan Chisholms exam questions #6:
class A {String s1 = "A.s1";
String s2 = "A.s2";}
class B extends A {
String s1 = "B.s1";
public static void main(String args[]) {
B x = new B(); A y = (A)x;
System.out.println(x.s1+" "+x.s2+" "+y.s1+" "+y.s2);
}}
Why does he use a cast here: A y = (A)x; ?