CPSC 112 Midterm: CS 112 Yale 13Fall Exam1 Solution
Document Summary
1. 1) (1 point) the easy one: check coversheet for name, recitation #, pennkey, and signature. String str = "java"; int z = 14 / str. length(); system. out. println(z); (a) 14 / 4 (b) 3 [this one] (c) 3. 5 (d) none, this code will result in an error. 2. 1) (7 points) give the data type and value that z contains in each of the following expressions. Your answers should not involve implicit or explicit casting. If the code fragment would result in an error, write n/a in the rst column, and give the reason for the error in the second column (you do not need to write the exact error message). Missing semicolon int y = 0, x = 1; ????? z = (y >= 0 && x < 0); boolean false. String s = math. max(4, 2); ????? z = s; String variable. double d = 3. 14; ????? z = d - (int) d; double.