Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Home
»
Java Programming
»
Flow Control
What will be the output of the program? int x = l, y = 6; while (y--) { x++; } System.out.println("x = " + x +" y = " + y);
x = 6 y = 0
x = 7 y = 0
x = 6 y = -1
Compilation fails.
Show Answer
Correct Answer:
Compilation fails.
Explanation:
Compilation fails because the while loop demands a boolean argument for it's looping condition, but in the code, it's given an int argument.
while(true) { //insert code here }
← Previous
Next →
Discussion & Comments
No comments yet. Be the first to comment!
Name:
Comment:
Post Comment