Advertisements
Advertisements
Question
Consider 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:
Options
42
4200
0
000
MCQ
Advertisements
Solution
00
Explanation:
Since there are no statements in the loop, no values of p are printed inside the loop. When the loop ends p has become 0. The last two print statements print the value of p, that is 00.
shaalaa.com
Is there an error in this question or solution?
2024-2025 (March) Official Board
