In Java, which loop is used when you want to execute a block of code as long as a condition is true?
A. for loop
B. while loop
C. switch loop
D. do-while loop
Answer: Option B
A. for loop
B. while loop
C. switch loop
D. do-while loop
Answer: Option B
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