Quiz #: 1 SAMPLE EXAM ----------------------------------------- 1. (15 points) What would the values of the following expressions be: a. 2 + 3 + 1 * 7 b. 1 % 5 c. 2 * 5 / 4 d. 5 * 8 % (3 + 1) e. 2.0 / 4 * 3 ANSWER: 2. (12 points) What is the output of the following instructions? Assume that the code is correctly implemented in a class and will work. int x = 15; int y = 25; boolean z = false; System.out.println( x == y || z ); System.out.println( x >= y – x ); System.out.println( !z || (x - y*5 / 2) < (y-x/2*8) ); System.out.println( (y % 5 == 0 ) && !(z || y>30) ); ANSWER: 3. (3 points) Declare a string and initialize its value to “Oh the horror of it all.”. ANSWER: 4. (6 points) Objects have state and behavior. Discuss these two properties in sufficient detail to indicate that you know what they mean and give an example for each. ANSWER: 5. (4 points) The following code won’t compile. Fix the two errors in it. Please use casting in your answer. float pi = 3.14; int wholeNumber = pi; ANSWER: 6. (3 points) What happens if a program tries access memory outside of the address range for that program? ANSWER: 7. Describe an appropriate use of the modulus operator in a game context. ANSWER: