Java Programming
primer-original-v2mediumJava Programming01 Introduction To Javaprimer-original-v2

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

Quick AnswerThe correct answer is 5,5 because it directly addresses the core logic of Java Programming.

This question has been retained as-is due to its unique context.

Related Java Programming questions

Practice more Java Programming questions

PrimerPrep has independently reviewed practice questions and coding exercises — all free.