COMP 248 Midterm: COMP 248 Midterm 2011 Fall C

128 views3 pages
31 Jan 2019
Department
Course
Professor

Document Summary

Comp 248 ee test 3 - a. Only encs-approved calculators (with the encs sticker) are allowed. No other electronic devices (including cell phones) are allowed. No books, papers or extra notes are allowed. Question 1 (20pts) what is the output produced by the following code segment: String word = "test3"; char c = "m"; if (c > "d" || word. charat(1) == "e") if (c < "g") Question 2 (20pts) what is the output produced by the following code segment: int price = 0; boolean isfree = (price == 0); if (isfree) price = 10; if (isfree) Question 3 (20pts) what is the output produced by the following code segment: int prevprev = 2; int prev = 2; int sum = 0; for (int i = 1; i < 4; i++) sum = prevprev + prev; System. out. println(prevprev + " " + prev + " " + sum); prevprev = prev; prev = sum;