Using Operators and Decision Constructs Flashcards
Only String, byte, char, short, int, (and their wrapper classes Byte, Character, Short, and Integer), and enums can be used as types of a switch variable.
+
The case constants must be assignable to the switch variable. For example, if your switch variable is of class String, your case labels must use Strings as well.
+
A boolean cannot be used for a switch statement. It needs an integral type, an enum, or a String.
+
A char value can ALWAYS be assigned to an int variable, since the int type is wider than the char type
+
Although it is not required for the exam to know the integral values of characters, it is good to know that all English letters (upper case as well as lower case) as well as 0-9 are below 127 and so are assignable to byte.
+
o1 and o2 denote two object references to two different objects of the same class.
The == operator compares whether the two references are pointing to the same object or not.
The concept is: || and && are short circuiting operation i.e. if the value of the expression can be known by just seeing the first part then the remaining part is not evaluated while | and & will always let all the parts evaluates.
+