# quiz4 - Name Section Dave's 15-100 M N O P Quiz 4 Reference...

This preview shows pages 1–3. Sign up to view the full content.

1 Name: ____________________ Section: M N O P Dave's 15-100 February 11, 2009 Quiz 4 Reference Robot void move () //before: front must be clear void turnLeft () void makeLight () //before: must be on dark void makeDark () //before: must be on light boolean frontIsClear () boolean onDark () 1. Consider the following code segment. int x; int y; int z; boolean b; x = 10; y = x * 2; x = x + 1; z = y; y = y + 1; b = x > 100; What are the final values of x , y , z , and b ? x : __________ y : __________ z : __________ b : __________

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 2. For each of the following code segments, indicate the number of times that the doSomething method will be called . For this problem only, you should assume that all variables have already been declared to be of type int . If the loop would not terminate, write infinite loop . (Hint: At least one of these code segments will enter an infinite loop.) a. i = 3; while (i != 0) { doSomething(); i = i - 1; } __________ b. max = 30; i = 0; while (i < max) { doSomething();
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 09/14/2010 for the course CS 15-100 taught by Professor Dave during the Spring '08 term at Carnegie Mellon.

### Page1 / 4

quiz4 - Name Section Dave's 15-100 M N O P Quiz 4 Reference...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online