Programming Languages Java Mcq
Sep 24, 2025

What is the output of the following code?\nint x = 5;\nint y = ++x;\nSystem.out.println(x + " " + y);

Choose the correct answer:
A) 5 5
B) 6 5
C) 5 6
D) 6 6
Detailed Explanation
++x is pre-increment, so x is incremented to 6 first, then assigned to y. Both x and y become 6.
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback