What is the result?

Given:
4. class Example {
5. int x = 50;
6. int y = 100;
7. public static void main(String args[]) {
8. int x = 0, y = 10;
9. Example ex = new Example();
10. while (x < 3) {
11. x++; y–;
12. }
13. System.out.println(“x = ” + x + ” , y = ” + y);
14. }
15. }
What is the result?

Given:
4. class Example {
5. int x = 50;
6. int y = 100;
7. public static void main(String args[]) {
8. int x = 0, y = 10;
9. Example ex = new Example();
10. while (x < 3) {
11. x++; y–;
12. }
13. System.out.println(“x = ” + x + ” , y = ” + y);
14. }
15. }
What is the result?

A.
Compilation fails because of an error at line 8.

B.
x = 3 , y = 7

C.
Compilation fails because of an error at line 11.

D.
Compilation fails because of an error at line 9.

E.
x = 53 , y = 97

F.
Compilation fails because of an error at line 10.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


saturn

saturn

> 11. x++; y–;
y- wrong sentence. Compilation will fail!
Answer is C, not B
Or change to y–;