6.14 Exercises, Problems, and Projects
6.14.1 Multiple Choice Exercises
-
1. How do you discover that you have an infinite loop in your code?
❑ The code does not compile.
❑ The code compiles and runs but gives the wrong result.
❑ The code runs forever.
❑ The code compiles, but there is a run-time error.
-
2. If you want to execute a loop body at least once, what type of loop would you use?
❑ for loop
❑ while loop
❑ do/while loop
❑ none of the above
-
3. What best describes a for loop?
❑ It is a count-controlled loop.
❑ It is an event-controlled loop.
❑ It is a sentinel-controlled loop.
-
4. You can simulate a for loop with a while loop.
❑ true
❑ false
6.14.2 Reading and Understanding Code
-
5. What is the output ...
Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.