JAVA FOR LOOP
Great choice 👍 Class 9 ICSE – Java for
Loop
I’ll explain low → high level, exactly as you want for classroom
teaching.
🔹 PART 1: MCQs (Low →
Moderate Level)
1. Which loop is used when the number of iterations is
known?
A. while
B. do-while
C. for
D. if
✅ Answer: C
2. What is the correct syntax of a for loop?
A. for(initialization; condition; increment)
B. for(condition; increment; initialization)
C. for(increment; condition; initialization)
D. for(initialization, condition, increment)
✅ Answer: A
3. How many times will this loop run?
for(int i=1; i<=5; i++)
A. 4
B. 5
C. 6
D. Infinite
✅ Answer: B
4. Which part of the for loop runs only once?
A. Condition
B. Increment
C. Initialization
D. Loop body
✅ Answer: C
5. Which operator is commonly used to increase loop value
by 1?
A. +=
B. ++
C. --
D. ==
✅ Answer: B
6. What will be the final value of i?
for(int i=0; i<3; i++)
A. 2
B. 3
C. 1
D. 0
✅ Answer: B
7. Which keyword is used to stop a loop immediately?
A. continue
B. stop
C. break
D. exit
✅ Answer: C
8. Which loop checks the condition first?
A. do-while
B. while
C. for
D. Both B and C
✅ Answer: D
9. What happens if the condition is always true?
A. Loop runs once
B. Compilation error
C. Infinite loop
D. Loop stops automatically
✅ Answer: C
10. Which variable is generally used in a for loop?
A. char
B. boolean
C. int
D. double
✅ Answer: C
🔹 PART 2: Important
Points for for Loop (MCQ Focus)
These points often come in ICSE MCQs 👇
- for
loop is an entry-controlled loop.
- Initialization
executes only once.
- Condition
is checked before every iteration.
- Increment/Decrement
executes after loop body.
- If
condition is false initially, loop runs zero times.
- break
stops the loop completely.
- continue
skips the current iteration.
- Loop
variable is usually of type int.
- Multiple
variables can be used in a for loop.
- Semicolon
; is compulsory between parts.
🔹 PART 3: Basic → High
Level CODE (NO FULL PROGRAM)
🟢 EASY LEVEL (3)
1️⃣ Print numbers 1 to 5
for(int i=1; i<=5; i++)
System.out.println(i);
2️⃣ Print Hello 3 times
for(int i=1; i<=3; i++)
System.out.println("Hello");
3️⃣ Print even numbers till 10
for(int i=2; i<=10; i+=2)
System.out.println(i);
🟡 NORMAL LEVEL (3)
4️⃣ Print numbers from 10 to 1
for(int i=10; i>=1; i--)
System.out.println(i);
5️⃣ Sum of first 5 numbers
int sum = 0;
for(int i=1; i<=5; i++)
sum += i;
6️⃣ Print square of numbers 1 to 5
for(int i=1; i<=5; i++)
System.out.println(i*i);
🔴 HARD LEVEL (4)
7️⃣ Count digits in a number
int count = 0;
for(; n>0; n/=10)
count++;
8️⃣ Reverse a number
int rev = 0;
for(; n>0; n/=10)
rev = rev*10 +
n%10;
9️⃣ Check palindrome logic
for(; n>0; n/=10)
rev = rev*10 +
n%10;
🔟 Nested for loop
(pattern logic)
for(int i=1; i<=3; i++)
for(int j=1;
j<=i; j++)
System.out.print("*");
🎯 Teaching Tip for You
(as ICSE Teacher)
Start with:
👉
Real-life example (attendance count, roll numbers)
👉
Then MCQ
👉
Then EASY code
👉
Finally HARD logic
If you want, I can also give:
- Board-exam
MCQs
- Worksheet
- Blackboard
explanation script
- Homework
questions
Just tell me 👍
🔹 PART 1: MCQs (Low →
Moderate Level)
1. Which loop is used when the number of iterations is
known?
A. while
B. do-while
C. for
D. if
✅ Answer: C
2. What is the correct syntax of a for loop?
A. for(initialization; condition; increment)
B. for(condition; increment; initialization)
C. for(increment; condition; initialization)
D. for(initialization, condition, increment)
✅ Answer: A
3. How many times will this loop run?
for(int i=1; i<=5; i++)
A. 4
B. 5
C. 6
D. Infinite
✅ Answer: B
4. Which part of the for loop runs only once?
A. Condition
B. Increment
C. Initialization
D. Loop body
✅ Answer: C
5. Which operator is commonly used to increase loop value
by 1?
A. +=
B. ++
C. --
D. ==
✅ Answer: B
6. What will be the final value of i?
for(int i=0; i<3; i++)
A. 2
B. 3
C. 1
D. 0
✅ Answer: B
7. Which keyword is used to stop a loop immediately?
A. continue
B. stop
C. break
D. exit
✅ Answer: C
8. Which loop checks the condition first?
A. do-while
B. while
C. for
D. Both B and C
✅ Answer: D
9. What happens if the condition is always true?
A. Loop runs once
B. Compilation error
C. Infinite loop
D. Loop stops automatically
✅ Answer: C
10. Which variable is generally used in a for loop?
A. char
B. boolean
C. int
D. double
✅ Answer: C
🔹 PART 2: Important
Points for for Loop (MCQ Focus)
- for
loop is an entry-controlled loop.
- It
is used when the number of iterations is known.
- Initialization
runs only once.
- Condition
is checked before every iteration.
- Increment/Decrement
runs after the loop body.
- If
the condition is false initially, loop executes zero times.
- break
terminates the loop immediately.
- continue
skips the current iteration.
- Multiple
statements can be written using { }.
- Nested
for loop means loop inside another loop.
🔹 PART 3: Codes (Basic →
High Level)
👉 NOTE FOR STUDENTS:
✍️
Write the TOTAL PROGRAM with OUTPUT in the notebook.
🟢 EASY LEVEL (3 Codes)
1️⃣ Print numbers from 1 to 5
for(int i = 1; i <= 5; i++)
{
System.out.println(i);
}
Output:
1
2
3
4
5
2️⃣ Print “Hello” 3 times
for(int i = 1; i <= 3; i++)
{
System.out.println("Hello");
}
Output:
Hello
Hello
Hello
3️⃣ Print even numbers from 2 to
10
for(int i = 2; i <= 10; i += 2)
{
System.out.println(i);
}
Output:
2
4
6
8
10
🟡 NORMAL LEVEL (3 Codes)
4️⃣ Print numbers from 10 to 1
for(int i = 10; i >= 1; i--)
{
System.out.println(i);
}
Output:
10
9
8
7
6
5
4
3
2
1
5️⃣ Find sum of first 5 natural
numbers
int sum = 0;
for(int i = 1; i <= 5; i++)
{
sum = sum + i;
}
System.out.println(sum);
Output:
15
6️⃣ Print square of numbers from 1
to 5
for(int i = 1; i <= 5; i++)
{
System.out.println(i * i);
}
Output:
1
4
9
16
25
🔴 HARD LEVEL (4 Codes)
7️⃣ Count digits in a number
int count = 0;
for(; n > 0; n = n / 10)
{
count++;
}
System.out.println(count);
Output (Example: n = 456):
3
8️⃣ Reverse a number
int rev = 0;
for(; n > 0; n = n / 10)
{
rev = rev * 10 + n
% 10;
}
System.out.println(rev);
Output (Example: n = 123):
321
9️⃣ Palindrome logic using for
loop
int rev = 0, temp = n;
for(; n > 0; n = n / 10)
{
rev = rev * 10 + n
% 10;
}
Output (Example: n = 121):
Palindrome
🔟 Nested for loop (Star
pattern)
for(int i = 1; i <= 3; i++)
{
for(int j = 1; j
<= i; j++)
{
System.out.print("*");
}
System.out.println();
}
Output:
*
**
***
🔹 PART 4: 10 MCQs (Final
– Board Practice)
21. Which loop is best when repetitions are fixed?
A. while
B. do-while
C. for
D. if
✅ Answer: C
22. How many times will this loop execute?
for(int i=1; i<5; i++)
A. 3
B. 4
C. 5
D. Infinite
✅ Answer: B
23. What does i++ mean?
A. i = i + 2
B. i = i - 1
C. i = i + 1
D. i = i × 1
✅ Answer: C
24. Which symbol separates parts of for loop?
A. :
B. ,
C. ;
D. .
✅ Answer: C
25. Which loop can be nested?
A. if
B. for
C. while
D. All of these
✅ Answer: D
26. What is the output?
for(int i=1; i<=1; i++)
System.out.println(i);
A. 0
B. 1
C. Infinite
D. Error
✅ Answer: B
27. Which keyword skips one iteration?
A. break
B. skip
C. continue
D. exit
✅ Answer: C
28. Which loop may never execute?
A. for
B. while
C. do-while
D. none
✅ Answer: A
29. Which value is checked again and again?
A. Initialization
B. Condition
C. Increment
D. Variable type
✅ Answer: B
30. Which loop is entry controlled?
A. do-while
B. for
C. switch
D. case
✅ Answer: B
Comments
Post a Comment