CPSC 112 Midterm: CS 112 Yale 13Fall Exam1 Solution

30 views9 pages
31 Jan 2019
Course
Professor

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents