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 👇

  1. for loop is an entry-controlled loop.
  2. Initialization executes only once.
  3. Condition is checked before every iteration.
  4. Increment/Decrement executes after loop body.
  5. If condition is false initially, loop runs zero times.
  6. break stops the loop completely.
  7. continue skips the current iteration.
  8. Loop variable is usually of type int.
  9. Multiple variables can be used in a for loop.
  10. 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)

  1. for loop is an entry-controlled loop.
  2. It is used when the number of iterations is known.
  3. Initialization runs only once.
  4. Condition is checked before every iteration.
  5. Increment/Decrement runs after the loop body.
  6. If the condition is false initially, loop executes zero times.
  7. break terminates the loop immediately.
  8. continue skips the current iteration.
  9. Multiple statements can be written using { }.
  10. 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

Popular posts from this blog

class 8 computer chapter 5

class 7 last chapter

CLASS 8 COMPUTER