Original Question:
Given the following code
class Base{
static int oak=99;
}
public class Doverdale extends Base{
public static void main(
String argv[]){
Doverdale d = new Doverdale();
d.amethod();
}
public void amethod(){
//Here
}
}
Which of the following if placed after the comment //Here, will compile and modify the value of the variable oak?
1) super.oak=1;
2) oak=33;
3) Base.oak=22;
4) oak=50.1;
The answers given is 1, 2, 3
I have to contend again here (sorry Marcus :-) that answer
1 is not correct, since in a static context, there is not
such thing as "super" or "this". So answer 1 is incorrect.
The correct answer is 2, 3.
Would anyone please comment? Thanks! Sam