Hello
I am just wondering about this code that i have, i dont think i know how polymorhism quite works, heres my code
class Base {
protected int size = 100;
public int getSize() {
return size;
}
}
class Runtime extends Base {
protected int size = 10;
public int getSize(){
return size;
}
public static void main(
String[] args) {
Runtime r = new Runtime();
System.out.println (r.size + "," + ((Base)r).getSize()); <-- problem
}
}
i dont understand why i get the result of 10,10 printed to the screen, i would have thought it was 10,100 because i cast my r object to Base.
Can anyone share in my frustration???
Cheers
Dave