1. int I=1, j=0
2.
3. switch(i) {
4. case 2:
5. j+=6;
6.
7. case 4:
8. j+=1;
9.
10. default:
11. j +=2;
12.
13. case 0:
14. j +=4;
15. }
16.
What is the value of j at line 16?()
A. 0
B. 1
C. 2
D. 4
E. 6
您可能感兴趣的试卷
你可能感兴趣的试题
public class WhileFoo {
public static void main (String []args) {
int x= 1, y = 6;
while (y--) {x--;}
system.out.printIn(“x=” + x “y =” + y);
}
}
What is the result?()
A. The output is x = 6 y = 0
B. The output is x = 7 y = 0
C. The output is x = 6 y = -1
D. The output is x = 7 y = -1
E. Compilation will fail.
public class X {
public static void main (String[] args) {
byte b = 127;
byte c = 126;
byte d = b + c;
}
}
Which statement is true?()
A. Compilation succeeds and d takes the value 253.
B. Line 5 contains an error that prevents compilation.
C. Line 5 throws an exception indicating “Out of range”
D. Line 3 and 4 contain error that prevent compilation.
E. The compilation succeeds and d takes the value of 1.
1. public class X {
2. public static void main (String[]args) {
3. int [] a = new int [1]
4. modify(a);
5. System.out.printIn(a[0]);
6. }
7.
8. public static void modify (int[] a) {
9. a[0] ++;
10. }
11. }
What is the result?()
A. The program runs and prints “0”
B. The program runs and prints “1”
C. The program runs but aborts with an exception.
D. An error “possible undefined variable” at line 4 causes compilation to fail.
E. An error “possible undefined variable” at line 9 causes compilation to fail.
public class X {
public static void main (String[]args) {
string s = new string (“Hello”);
modify(s);
System.out.printIn(s);
}
public static void modify (String s) {
s += “world!”;
}
}
What is the result?()
A. The program runs and prints “Hello”
B. An error causes compilation to fail.
C. The program runs and prints “Hello world!”
D. The program runs but aborts with an exception.
public class Foo {
public static void main (String []args) {
int i = 1;
int j = i++;
if ((i>++j) && (i++ ==j)) {
i +=j;
}
}
}
What is the final value of i?()
A. 1
B. 2
C. 3
D. 4
E. 5
public class X {
public static void main (String[]args) {
String s1 = new String (“true”);
Boolean b1 = new Boolean (true);
if (s2.equals(b1)) {
System.out.printIn(“Equal”);
}
}
}
What is the result?()
A. The program runs and prints nothing.
B. The program runs and prints “Equal”
C. An error at line 5 causes compilation to fail.
D. The program runs but aborts with an exception.
String foo = “blue”;
Boolean[]bar = new Boolean [1];
if (bar[0]) {
foo = “green”;
}
What is the result? ()
A. Foo has the value of “”
B. Foo has the value of null.
C. Foo has the value of “blue”
D. Foo has the value of “green”
E. An exception is thrown.
F. The code will not compile.
A. Char ch = “a”;
B. Char ch = ‘\’ ‘;
C. Char ch = ‘cafe’;
D. Char ch = “cafe”;
E. Char ch = ‘\ucafe’;
F. Char ch = ‘\u10100’;
G. Char ch = (char) true;
public class foo {
static String s;
public static void main (String[]args) {
system.out.printIn (“s=” + s);
}
}
What is the result?()
A. The code compiles and “s=” is printed.
B. The code compiles and “s=null” is printed.
C. The code does not compile because string s is not initialized.
D. The code does not compile because string s cannot be referenced.
E. The code compiles, but a NullPointerException is thrown when toString is called.
public interface Foo{
int k = 4;
}
Which three are equivalent to line 2?()
A. Final int k = 4;
B. Public int k = 4;
C. Static int k = 4;
D. Private int k = 4;
E. Abstract int k = 4;
F. Volatile int k = 4;
最新试题
What is the result?()
Which statement is true about the set variable on line 12?()
Which three changes should be made to adapt this class to be used safely by multiple threads?()
Which statement is true?()
Given that t1 is a reference to a live thread, which is true?()
Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()
Which statement is true?()
What is the result?()
What is the result?()
What is the result?()