Java Reference
In-Depth Information
10. What is the result of the following code?
5. int m = 9, n = 1;
6. int x = 0;
7. while(m > n) {
8. m--;
9. n += 2;
10. x += m + n;
11. }
12. System.out.println(x);
A. 11
B. 13
C. 23
D. 36
E. 50
11. Given the following class definition:
1. public class Forever {
2. public void run() {
3. while(true) {
4. System.out.println(“Hello”);
5. }
6. System.out.println(“Goodbye”);
7. }
8. }
what is output of the following statement?
new Forever().run();
A. Prints Hello indefinitely
B. Prints Hello until an error occurs
C. Prints Hello until an error occurs, then prints Goodbye
D. Compiler error on line 3
E. Compiler error on line 6
12. What is the result of the following code?
7. int y = 1;
8. do {
9. System.out.print(y + “ “);
10. }while(y <= 10);
Search WWH ::




Custom Search