🎴 Flashcard Mode
Java Servlets and Core Programming
Card1 / 20
Mastered0
Review0
QuestionClick to flip
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); } }
AnswerClick to flip back
A
I am in do-while
💡 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.