Java Loops MCQs with answers Page - 4

You will find multiple-choice questions (MCQs) related to #Java Loops here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

A

Admin • 828.43K Points
Coach

Q. Which is true about a do-while loop?

  • (A) The condition is checked before the loop body
  • (B) It executes the loop body at most once
  • (C) It executes the loop body at least once
  • (D) It is the same as a while loop

A

Admin • 828.43K Points
Coach

Q. Which loop is entry-controlled in Java?

  • (A) do-while
  • (B) while
  • (C) for
  • (D) both while and for

A

Admin • 828.43K Points
Coach

Q. How can you create an infinite loop using for?

  • (A) for(;;)
  • (B) for(1;;)
  • (C) for(;;1)
  • (D) for(int i=0;;i++)

A

Admin • 828.43K Points
Coach

Q. What will the following print?
int x = 5;
do {
System.out.print(x);
} while(x < 5);

  • (A) 5
  • (B) nothing
  • (C) 6
  • (D) infinite loop

A

Admin • 828.43K Points
Coach

Q. What is the purpose of a loop counter?

  • (A) To create infinite loops
  • (B) To avoid syntax errors
  • (C) To control the number of loop iterations
  • (D) To store results

A

Admin • 828.43K Points
Coach

Q. How do you skip the rest of a loop and start the next iteration?

  • (A) break
  • (B) return
  • (C) continue
  • (D) goto

A

Admin • 828.43K Points
Coach

Q. What happens if the loop condition is always true and no break is used?

  • (A) Syntax error
  • (B) Only one iteration
  • (C) Infinite loop
  • (D) Compilation error

A

Admin • 828.43K Points
Coach

Q. Which loop is ideal for iterating over arrays?

  • (A) while
  • (B) do-while
  • (C) for
  • (D) for-each

A

Admin • 828.43K Points
Coach

Q. What is the output?
int[] arr = {1,2,3};
for(int i : arr) {
System.out.print(i + " ");
}

  • (A) 123
  • (B) 1 2 3
  • (C) i i i
  • (D) error

A

Admin • 828.43K Points
Coach

Q. What is the output?
int i = 10;
while(i < 10) {
System.out.println(i);
i++;
}

  • (A) 10
  • (B) Nothing
  • (C) 10 11
  • (D) Infinite loop
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More