Java Programming
Accenture PrimermediumJava Programming01 Introduction To Java

Accenture Java Programming Practice Question

What will be the output of the program? Given: 10. int x = 0; 11. int y = 10; 12. do { 13. y--; 14. ++x; 15. } while (x < 5); 16. System.out.print(x + "," + y); What is the result?

Answer options

A
6,5
B
5,5
C
5,6
D
6,6 x is assigned 0 and y, 10 initially. During each iteration x is incremented by 1 and y is decremented by 1. The iteration stops when x equals 5. At this stage y also would have reached the value 5. Hence the output 5 5.

Correct answer: 5,5

Explanation

Correct answer: 5,5.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerDumps has 1400+ primer questions, 2026 mocks and coding hands-on — all free.