Multiple choice technology programming languages

package loop; public class TestLoop2 { public static void main(String[] args) { int p = 100; do { while(p>100) { System.out.println("I am in while"); } System.out.println("I am in do-while"); } while (p > 100); } }

  1. I am in do-while

  2. I am in while I am in do-while

  3. Compiler Error

  4. No output

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The do-while loop executes once because the condition is checked at the end. Inside, the while loop condition p>100 is initially false (p equals 100), so it never executes. Therefore, only the do-while body prints once.

AI explanation

p is initialized to 100 and never changes, so p > 100 is false from the start. The inner while(p>100) never runs because its condition is immediately false. The do { ... } while(p>100) block always executes its body at least once, printing "I am in do-while", and then the loop condition p>100 is false so it exits without looping again. Only that single line is printed.