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.
相关问题推荐
-
What is the result?()
A、 12,4
B、 The code runs with no output.
C、 An exception is thrown at runtime.
D、 Compilation fails because of an error in line 21.
E、 Compilation fails because of an error in line 22.
F、 Compilation fails because of an error in line 31.
-
public class ItemTest { private final mt id; public ItemTest(int id) { this.id = id; } public void updateId(int newId) { id = newId; } public static void main(String[] args) { ItemTest fa = new ItemTest(42); fa.updateId(69); System.out.println(fa.id); } } What is the result?()
A、 Compilation fails.
B、 An exception is thrown at runtime.
C、 The attribute id in the Item object remains unchanged.
D、 The attribute id in the Item object is modified to the new value.
E、 A new Item object is created with the preferred value in the id attribute.
-
Which line contains a constructor in this class definition?() public class Counter { // (1) int current, step; public Counter(int startValue, int stepValue) { // (2) set(startValue); setStepValue(stepValue); } public int get() { return current; } // (3) public void set(int value) { current = value; } // (4) public void setStepValue(int stepValue) { step = stepValue; } // (5) }
A、Code marked with (1) is a constructor
B、Code marked with (2) is a constructor
C、Code marked with (3) is a constructor
D、Code marked with (4) is a constructor
E、Code marked with (5) is a Constructor
-
public static void test(String str) { int check = 4; if (check = str.length()) { System.out.print(str.charAt(check -= 1) +“, “); } else { System.out.print(str.charAt(0) + “, “); } } and the invocation: test(”four”); test(”tee”); test(”to”); What is the result?()
A、 r, t, t,
B、 r, e, o,
C、 Compilation fails.
D、 An exception is thrown at runtime.
-
Which exception or error will be thrown when a programmer attempts to run this code?()
A、 java.lang.StackOverflowError
B、 java.lang.IllegalStateException
C、 java.lang.ExceptionInInitializerError
D、 java.lang.ArrayIndexOutOfBoundsException