Hello
Hello World
Compilation fails.
Hello World 5
The code runs with no output.
An exception is thrown at runtime.
第1题:
public class Alpha{ public static void main( string[] args ){ if ( args.length == 2 ) { if ( args.[0].equalsIgnoreCase(“-b”) ) System.out.println( new Boolean( args[1] )); } } } And the code is invoked by using the command: java Alpha –b TRUE What is the result?()
第2题:
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?()
第3题:
String a = null; a.concat(“abc”); a.concat(“def”); System.out.println(a); What is the result?()
第4题:
class Base { Base() { System.out.print(“Base”); } } public class Alpha extends Base { public static void main( String[] args ) { new Alpha(); new Base(); } } What is the result?()
第5题:
Hello
Hello World
Compilation fails.
Hello World 5
The code runs with no output.
An exception is thrown at runtime.
第6题:
Cat
Dog
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第7题:
Compilation fails.
ClassC is displayed.
The code runs with no output.
An exception is thrown at runtime.
第8题:
Base
BaseBase
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第9题:
Hello
Hello World
Compilation fails.
Hello World 5
The code runs with no output.
第10题:
peep
bark
meow
Compilation fails.
An exception is thrown at runtime.
第11题:
true
null
false
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第12题:
1
2
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第13题:
Runnable r = new Runnable() { public void run() { System.out.print(”Cat”); } }; Threadt=new Thread(r) { public void run() { System.out.print(”Dog”); } }; t.start(); What is the result?()
第14题:
10. public class Hello { 11. String title; 12. int value; 13. public Hello() { 14. title += “ World”; 15. } 16. public Hello(int value) { 17. this.value = value; 18. title = “Hello”; 19. Hello(); 20. } 21. } and: 30. Hello c = new Hello(5); 31. System.out.println(c.title); What is the result?()
第15题:
public class ClassA { public int getValue() { int value=0; boolean setting = true; String title=”Hello”; (value || (setting && title == “Hello”)) { return 1; } (value == 1 & title.equals(”Hello”)) { return 2; } } } And: ClassA a = new ClassA(); a.getValue(); What is the result?()
第16题:
collie
harrier
Compilation fails.
collie harrier
An exception is thrown at runtime.
第17题:
r, t, t,
r, e, o,
Compilation fails.
An exception is thrown at runtime.
第18题:
abc
null
abcdef
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第19题:
TestA
TestB
Compilation fails.
An exception is thrown at runtime.
第20题:
An exception is thrown at runtime.
int Long
Compilation fails.
Short Long
第21题:
An exception is thrown at runtime.
r, e, o,
Compilation fails.
r, t, t,
第22题:
Hello
Hello Foo
Hello world
Compilation fails.
The code does not run.
第23题:
1
2
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.