Wednesday, February 24, 2010

SCJP exercise : operators

Exercise :

public static void main(String [] args) {

int val = 5;
if ( (val && 7) == 2) {
System.out.println("Good");
} else {
System.out.println("Bad");
}
}

A Good
B Bad
C Compilation fails
D An exception is thrown at runtime










Solution :


The solution is C.The && oeprator can be use only with boolean.