Is it legal: int x = 1; x = ~x; : Questions « Operators « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Operators » Questions 
2.11.7.Is it legal: int x = 1; x = ~x;
A. It is legal.
B. It is illegal.
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.