Java Reference
In-Depth Information
5. What is the result of the following code?
4. final char a = 'A', d = 'D';
5. char grade = 'B';
6. switch(grade) {
7. case a :
8. case 'B' :
9. System.out.print(“great”);
10. case 'C' :
11. System.out.print(“passed”);
12. break;
13. case d :
14. case 'F' :
15. System.out.print(“not good”);
16. }
A. great
B. greatpassed
C. Compiler error on line 4
D. Compiler error on line 7
E. Compiler errors on lines 7 and 13
6. What is the result of the following code?
4. char c = a;
5. for(int i = 1; i <= 3; i++) {
6. for(int j = 0; j <= 2; j++) {
7. System.out.print(c++);
8. }
9. }
A. abcdefghi
B. bcdefghij
C. abcdef
D. abcabcabc
E. The code does not compile.
7. What is the result of the following code?
10. String [] values = {“one”, “two”, “three”};
11. for(int index = 0; index < values.length; index++) {
12. System.out.print(values[index]);
13. }
14. System.out.print(index);
Search WWH ::




Custom Search