aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • Java Programming Fundamentals
  • Output for the below code : int i = 10; while (++i <= ...
Multiple choice technology programming languages

Output for the below code : int i = 10; while (++i <= 10) { i++; } System.out.print(i);

  1. 10

  2. 11

  3. 12

  4. Line 5 will be never reached

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The while condition uses pre-increment (++i): i becomes 11 first, then 11 <= 10 is evaluated as false. The loop body never executes, and i remains 11. The output is '11'.

Keep practicing — related questions

  • Given: 25.intx=12; 26. while (x < 10) { 27. x--; 28. } 29. System.out.print(x); What is the result?
  • int x = 12; while (x < 10) { x--; } System.out.print(x); What is the result?
  • int x = 12; while (x < 10) { x--; } System.out.print(x); What is the result?
  • What will be the output of the program? int i = 1, j = 10; do { if(i++ > --j) /* Line 4 */ { continue; } } ...
  • Give the output of the following: int n=10; while (true) {if (n<5) continue; n=n-2;} System.out.println(n);
  • What will be the output of the program? int i = O; while(1) { if(i == 4) { break; } ++i; } System.out.print...
  • int x = 0; int y = 10; do { y--; ++x; } while (x < 5); System.out.print(x + "," + y); What is the result?
  • Find the output of the following C program: main(){int i=0;while(++i<=10) printf(%d, i);}
Play the full quiz 🎤 Practise this topic out loud

Practice this topic

  • Programming Output Evaluation (1721 questions)
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy