• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer

Java Tutorials Online

  • CORE JAVA
  • SERVLET

Java For Loop Intermediate-Level MCQs

Core Java For Loop Intermediate MCQs

Java For Loops are essential for handling iterations efficiently.This intermediate-level set will help you bridge the gap between basic and advanced concepts. Practicing Java For Loop Intermediate-Level MCQs can improve your understanding and coding skills.

Don’t forget to check out our other sets for different difficulty levels:

  • Java For Loop Beginner-Level MCQs [Click here]
  • Java For Loop Advanced-Level MCQs [Click here]

For more intermediate Java topics, you can also explore additional resources on Java official documentation.


For Loop MCQ Questions (Medium)

Ready to test your knowledge? Let’s dive into some multiple-choice questions to reinforce your understanding of intermediate Java For Loops.

Question 1:

What will be the output of the following code?

for (int i = 1; i <= 5; i++) {
    System.out.print(i * i + " ");
}
A
B
C
View Answer

Correct Answer: C


The loop prints the square of each number from 1 to 5, which results in: 1 4 9 16 25.

Question 2:

Which code snippet will print the numbers 5 10 15 20?

A
B
C
View Answer

Correct Answer: B


Option 2 iterates from 5 to 20 in steps of 5, producing the correct sequence: 5 10 15 20.

Question 3:

What is the output of this code?

for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 2; j++) {
        System.out.print(i * j + " ");
    }
}
A
B
C
View Answer

Correct Answer: B


The nested loop multiplies i and j, producing the sequence: 1 2 2 4 3 6 4 8.

Question 4:

Which code snippet produces the same result?

for (int i = 1; i <= 3; i++) {
    System.out.print(i + " ");
}
A
B
C
View Answer

Correct Answer: C


Option 3 produces the same output by iterating from 0 to 2 and adding 1 to each iteration value.

Question 5:

What will be the output of this code?

for (int i = 10; i > 0; i -= 2) {
    System.out.print(i + " ");
}
A
B
C
View Answer

Correct Answer: C


The loop iterates with a decrement of 2, printing the sequence: 10 8 6 4 2.

Question 6:

Which code will output '1 2 4 8 16'?

A
B
C
View Answer

Correct Answer: A


Option 1 uses `Math.pow` to print the powers of 2: 1 2 4 8 16.

Question 7:

What will this code output?

for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
        System.out.print(i * j + " ");
    }
}
A
B
C
View Answer

Correct Answer: B


The nested loop multiplies i and j, producing: 1 2 3 2 4 6 3 6 9.

Question 8:

Which loop will print 'A B C D E'?

A
B
C
View Answer

Correct Answer: C


Option 1 correctly loops from 'A' to 'E' and prints each letter: A B C D E.

Question 9:

What will be the output of this loop?

for (int i = 1; i <= 5; i++) {
    System.out.print(i + " ");
    if (i == 3) break;
}
A
B
C
View Answer

Correct Answer: A


The loop breaks after printing '3', so the output is: 1 2 3.

Question 10:

Which code snippet will print '5 10 15 20'?

A
B
C
View Answer

Correct Answer: C


Option 2 loops from 1 to 4 and prints multiples of 5, resulting in: 5 10 15 20.

Question 11:

What will be the output of this code?

for (int i = 1; i <= 5; i++) {
    System.out.print(i + " ");
    if (i == 3) continue;
}
A
B
C
View Answer

Correct Answer: B


The `continue` statement skips the 3rd iteration, printing: 1 2 4 5.

Question 12:

Which code will print '1 1 2 4 8'?

A
B
C
View Answer

Correct Answer: C


Option 1 prints the powers of 2: 1 2 4 8.

Question 13:

What will be the output of this loop?

for (int i = 5; i > 0; i--) {
    System.out.print(i + " ");
}
A
B
C
View Answer

Correct Answer: A


The loop runs backwards, printing: 5 4 3 2 1.

Question 14:

Which code will output '1 2 3 4 5'?

A
B
C
View Answer

Correct Answer: B


Both option 1 and 2 will print the numbers: 1 2 3 4 5.

Question 15:

Which code will produce '2 4 6 8 10'?

A
B
C
View Answer

Correct Answer: B


Option 1 correctly iterates from 2 to 10 in steps of 2, printing the even numbers.

Question 16:

What will be the output of this code?

for (int i = 1; i <= 5; i++) {
    System.out.print(i + " ");
    if (i == 3) break;
}
A
B
C
View Answer

Correct Answer: C


The loop breaks at the 3rd iteration, so the output is: 1 2 3.

Question 17:

What is the output of the following code?

for (int i = 1; i <= 5; i++) {
    System.out.print(i * i + " ");
}
A
B
C
View Answer

Correct Answer: C


The loop prints the square of each number from 1 to 5: 1 4 9 16 25.

Question 18:

Which code will print '1 3 5 7 9'?

A
B
C
View Answer

Correct Answer: A


Option 1 correctly calculates the odd numbers between 1 and 9: 1 3 5 7 9.

Question 19:

What will be the output of this code?

for (int i = 2; i <= 6; i += 2) {
    for (int j = 1; j <= 3; j++) {
        System.out.print(i * j + " ");
    }
}
A
B
C
View Answer

Correct Answer: A


The nested loop multiplies i and j, producing: 2 4 6 4 8 12 6 12 18.

Question 20:

Which loop will print '1 2 3 4 5 6 7 8 9 10'?

A
B
C
View Answer

Correct Answer: A


Option 1 will correctly print the numbers from 1 to 10.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • Java Do-While Loop: Practice MCQs
  • Test Post for WordPress
  • Test Post for WordPress
  • Java Array MCQs: Easy-Level Practice Questions
  • Java While Loop: Practice MCQs

Recent Comments

    Archives

    • January 2025

    Categories

    Footer

    Design

    With an emphasis on typography, white space, and mobile-optimized design, your website will look absolutely breathtaking.

    Learn more about design.

    Content

    Our team will teach you the art of writing audience-focused content that will help you achieve the success you truly deserve.

    Learn more about content.

    Strategy

    We help creative entrepreneurs build their digital business by focusing on three key elements of a successful online platform.

    Learn more about strategy.

    Copyright © 2025 · Magazine Pro on Genesis Framework · WordPress · Log in