# Review Exercises (Set A1)

1. String word = "CS170 abcd";
int i = 4;
int j = 20;
char c = 'd';


Assuming the above declarations and assignments have been made, give a literal of the correct type that is equivalent (in the "==" sense) to each of the following:

1. c + 5
105

2. ++i
5

2. the six numerical primitive types: byte, short, int, long, float, double
those stored approximately: float, double

3. Which of the following are legal names for variables in Java?

1. 1stNum
2. num1
3. myChar_
4. \$tempBoolean
5. while

(b), (c), and (d); (the first choice is illegal as you can't start a variable name with a digit, the last is illegal as "while" is a reserved word)
4. 11011001

5. 1 0111110 100110011001100110011010

6. E5A10F71(16)

7. P   Q   R   P^Q   P||R   !(P||R)   (P^Q)&&(!(P||R))
T   T   T    F      T      F              F
T   T   F    F      T      F              F
T   F   T    T      T      F              F
T   F   F    T      T      F              F
F   T   T    T      T      F              F
F   T   F    T      F      T              T
F   F   T    F      T      F              F
F   F   F    F      F      T              F