public class Test {
public static void main (String args) {
string foo = “blue”;
string bar = foo;
foo = “green”;
System.out.printIn(bar);
}
}
What is the result?()
A. An exception is thrown.
B. The code will not compile.
C. The program prints “null”
D. The program prints “blue”
E. The program prints “green”
您可能感兴趣的试卷
你可能感兴趣的试题
A. Java.io.InputStream.
B. Java.io.EncodedReader.
C. Java.io.InputStreamReader.
D. Java.io.InputStreamWriter.
E. Java.io.BufferedInputStream.
A. New dataInputStream(“in.txt”);
B. New dataInputStream(new file(“in.txt”));
C. New dataInputStream(new writer(“in.txt”));
D. New dataInputStream(new FileWriter(“in.txt”));
E. New dataInputStream(new InputStream(“in.txt”));
F. New dataInputStream(new FileInputStream(“in.txt”));
public class Foo implements Runnable (
public void run (Thread t) {
system.out.printIn(“Running.”);
}
public static void main (String args) {
new thread (new Foo()).start();
}
)
What is the result?()
A. An exception is thrown.
B. The program exists without printing anything.
C. An error at line 1 causes compilation to fail.
D. An error at line 6 causes the compilation to fail.
E. “Running” is printed and the program exits.
A. Exiting from a synchronized block.
B. Calling the wait method on an object.
C. Calling the notify method on an object.
D. Calling the notifyAll method on an object.
E. Calling the setPriority method on a thread object.
public class ForBar {
public static void main(String args) {
int i = 0, j = 5;
tp: for (;;) {
i ++;
for(;;)
if(i > --j) break tp;
}
system.out.printIn(“i = ” + i + “, j = “+ j);
}
}
What is the result? ()
A. The program runs and prints “i=1, j=0”
B. The program runs and prints “i=1, j=4”
C. The program runs and prints “i=3, j=4”
D. The program runs and prints “i=3, j=0”
E. An error at line 4 causes compilation to fail.
F. An error at line 7 causes compilation to fail.
A. Error
B. Event
C. Object
D. Exception
E. Throwable
F. RuntimeException
public class SwitchTest {
public static void main (String args) {
System.out.PrintIn(“value =” +switchIt(4));
}
public static int switchIt(int x) {
int j = 1;
switch (x) {
case 1: j++;
case 2: j++;
case 3: j++;
case 4: j++;
case 5: j++;
default:j++;
}
return j + x;
}
}
What is the output from line 3? ()
A. Value = 3
B. Value = 4
C. Value = 5
D. Value = 6
E. Value = 7
F. Value = 8
public class ExceptionTest {
class TestException extends Exception {}
public void runTest () throws TestException {}
public void test () /* Point X*/ {
runTest ();
}
}
At point X on line 4, which code can be added to make the code compile?()
A. Throws Exception.
B. Catch (Exception e).
C. Throws RuntimeException.
D. Catch (TestException e).
E. No code is necessary.
A. int ia = new int [15];
B. float fa = new float [20];
C. char ca = “Some String”;
D. Object oa = new float[20];
E. Int ia = (4, 5, 6) (1, 2, 3)
public class Test {
public static void main (String args) {
class Foo {
public int i = 3;
}
Object o = (Object) new Foo();
Foo foo = (Foo)o;
System.out.printIn(foo. i);
}
}
What is the result?()
A. Compilation will fail.
B. Compilation will succeed and the program will print “3”
C. Compilation will succeed but the program will throw a ClassCastException at line 6.
D. Compilation will succeed but the program will throw a ClassCastException at line 7.
最新试题
What is the result?()
A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()
Which statement is true about the set variable on line 12?()
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5?()
Given that t1 is a reference to a live thread, which is true?()
What is the result?()
What is the result?()
Which two of statements are true?()
What is the result?()
What is the result?()