MCQ Single Best Answer Moderate

QConsider the program segment:

int p = 0;
for (p = 4; p > 0; p -= 2);
System.out.print(p);
System.out.println(p);

The above statements will display:

ID: #24165 ICSE Computer Application - Class X - 2025 PYQ 208 views
Question Info
#24165Q ID
ModerateDifficulty
ICSE Computer Application - Class X - 2025 PYQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A 42
  • B 420
  • D 00
Correct Answer: Option C

Explanation

(c) 0
Explanation:

  • The for loop runs but does nothing (; at the end).

  • p starts at 4, then decreases by 2 until p > 0 fails (p = 0).

  • The final value of p is printed twice as 0.

Share This Question

Challenge a friend or share with your study group.