单项选择题
public class Test {
public static void replaceJ(string text) {
text.replace (‘j’, ‘l’);
}
public static void main(String args[]) {
string text = new String (“java”)
replaceJ(text);
system.out.printIn(text);
}
}
What is the result?()
A. The program prints “lava”
B. The program prints “java”
C. An error at line 7 causes compilation to fail.
D. Compilation succeeds but the program throws an exception.
相关考题
-
多项选择题
public class Foo { private int val; public foo(int v) (val = v;) } public static void main (String [] args) { Foo a = new Foo (10); Foo b = new Foo (10); Foo c = a; int d = 10; double e = 10.0; } Which three logical expression evaluate to true?()
A. (a ==c)
B. (d ==e)
C. (b ==d)
D. (a ==b)
E. (b ==c)
F. (d ==10.0) -
单项选择题
public class Test { public static void leftshift(int i, int j) { i<<=j; } public static void main(String args[]) { int i = 4, j = 2; leftshift(i, j); System.out.printIn(i); } } What is the result?()
A. 2
B. 4
C. 8
D. 16
E. The code will not compile. -
单项选择题
public class SyncTest { private int x; private int y; public synchronized void setX (int i) (x=1;) public synchronized void setY (int i) (y=1;) public synchronized void setXY(int 1)(set X(i); setY(i);) public synchronized Boolean check() (return x !=y;) } Under which conditions will check () return true when called from a different class?
A. Check() can never return true.
B. Check() can return true when setXY is called by multiple threads.
C. Check() can return true when multiple threads call setX and setY separately.
D. Check() can only return true if SyncTest is changed to allow x and y to be set separately.
