单项选择题
public class TestString 1 {
public static void main(String[] args) {
String str = “420”;
str += 42;
System.out.print(str);
}
}
What is the output?()
A. 42
B. 420
C. 462
D. 42042
E. Compilation fails.
F. An exception is thrown at runtime.
相关考题
-
单项选择题
1. public class Boxer1 { 2. Integer i; 3. int x; 4. public Boxer1(int y) { 5. x=i+y; 6. System.out.println(x); 7. } 8. public static void main(String[] args) { 9. new Boxer1(new Integer(4)); 10. } 11. } What is the result?()
A. The value “4” is printed at the command line.
B. Compilation fails because of an error in line 5.
C. Compilation fails because of an error in line 9.
D. A NullPointerException occurs at runtime.
E. A NumberFormatException occurs at runtime.
F. An IllegalStateException occurs at runtime. -
单项选择题
10. public class ClassA { 11. public void count(int i) { 12. count(++i); 13. } 14. } And: 20. ClassA a = new ClassA(); 21. a.count(3); Which exception or error should be thrown by the virtual machine?()
A. StackOverflowError
B. NullPointerException
C. NumberFormatException
D. IllegalArgumentException
E. ExceptionlnlnitializerError -
单项选择题
public class Foo { static int[] a; static { a[0]=2; } public static void main( String[] args) {} } 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.ExceptionlnlnitializerError
D. java.lang.ArraylndexOutOfBoundsException
