Answer: ! operator and boolean expression : Questions « Operators « SCJP






A.

The expression ( x - 3 ) is a boolean type and the ! operator can be applied to it.
 
public class MainClass{
    public static void main(String[] argv){
       int x = 1; if (!(x > 3)) {System.out.println(x);}
    
    
    }
}
1








2.11.Questions
2.11.1.What are the values of the variables x, a, and b?
2.11.2.Answer: pre-increament operator
2.11.3.Is it legal for int x = 1; x = !x;
2.11.4.Answer: ! operator and int value
2.11.5.Is it legal for int x = 1; if (!(x > 3)) {System.out.println(x);}
2.11.6.Answer: ! operator and boolean expression
2.11.7.Is it legal: int x = 1; x = ~x;
2.11.8.Answer: ~ binary operator and int value
2.11.9.What is printed out value (int x = -1; x = x >>> 5;)
2.11.10.Answer: shift operator and int value
2.11.11.What is the printed value (int x = -1; x = x >>> 32;)
2.11.12.Answer: shift and int value
2.11.13.What is the printed out value (byte x = -1; x = x >>> 5;)
2.11.14.Answer: shift and negative value
2.11.15.What is the output value (int x = -1; x = x >> 5;)?
2.11.16.Answer: negative value and shifting
2.11.17.Is it legal: String x = "Hello"; int y = 9; x += y;
2.11.18.Answer operation between int and string