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
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option C
Explanation
(c) 0
Explanation:
-
The
forloop runs but does nothing (;at the end). -
pstarts at4, then decreases by2untilp > 0fails (p = 0). -
The final value of
pis printed twice as0.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic