04review - Chapter 4 Loops 1. (A) The loop body is not...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 4 Loops 1. (A) The loop body is not executed. (B) The loop body is executed nine times. The printout is 2, 4, 6, 8 on separate lines. 2. The difference between a do-while loop and a while loop is the order of evaluating the continuation-condition and executing the loop body. In a while loop, the continuation-condition is checked and then, if true, the loop body is executed. In a do-while loop, the loop body is executed for the first time before the continuation- condition is evaluated. 3. Same. When the i++ and ++i are used in isolation, their effects are same. 4. The three parts in a for loop control are as follows: The first part initializes the control variable. The second part is a Boolean expression that determines whether the loop will repeat. The third part is the adjustment statement, which adjusts the control variable. for (int i=1,i<=100,i++) System.out.println(i); 5. The loop keeps doing something indefinitely. 6.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/17/2012 for the course GCIS 501 taught by Professor Liu during the Fall '09 term at Gannon.

Page1 / 4

04review - Chapter 4 Loops 1. (A) The loop body is not...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online