Which of the following is a valid way to create an infinite loop in Java?
A. switch (1) { /* loop body */ }
B. do { /* loop body */ } while (false);
C. for (int i = 0; i < 5; i--) { /* loop body */ }
D. while (true) { /* loop body */ }
Answer: Option D
Related Questions on Flow Control
What is the purpose of the "if" statement in Java?
A. To execute a block of code conditionally
B. To create loops
C. To declare variables
D. To define methods
A. No output
B. Error
C. Hello
D. 5
Join The Discussion