Hi, in the following code :
public class Test {
static int total = 10;
public static void main (String args []) {
new Test();
}
public Test () {
System.out.println("In test");
System.out.println(this);
int temp = this.total;
if (temp > 5) {
System.out.println(temp);
}}}
A.The compiler reports an error at line 2
B.The class will not compile
C.The value 10 is one of the elements printed to the standard output
D.The compiler reports an error at line 9
E.The class compiles but generates a runtime error
Can anyone explain why the answer is C and not D ?
Thanks
Stephane
public class Test {
static int total = 10;
public static void main (String args []) {
new Test();
}
public Test () {
System.out.println("In test");
System.out.println(this);
int temp = this.total;
if (temp > 5) {
System.out.println(temp);
}}}
A.The compiler reports an error at line 2
B.The class will not compile
C.The value 10 is one of the elements printed to the standard output
D.The compiler reports an error at line 9
E.The class compiles but generates a runtime error
Can anyone explain why the answer is C and not D ?
Thanks
Stephane