ab
bc
abc
Compilation fails.
An exception is thrown at runtime.
第1题:
public class Yippee2 { static public void main(String [] yahoo) { for(int x= 1; x
第2题:
interface DeclareStuff{ public static final int EASY = 3; void doStuff(int t); } public class TestDeclare implements DeclareStuff { public static void main(String [] args) { int x=5; new TestDeclare().doStuff(++x); } void doStuff(int s) { s += EASY + ++s; System.out.println(”s “ + s); } } What is the result?()
第3题:
A.ab
B.bc
C.abc
D.Compilation fails.
E.An exception is thrown at runtime.
第4题:
class TestA { public void start() { System.out.println(”TestA”); } } public class TestB extends TestA { public void start() { System.out.println(”TestB”); } public static void main(String[] args) { ((TestA)new TestB()).start(); } } What is the result?()
第5题:
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?()
第6题:
public static void main(String[] args) { String str = “null‟; if (str == null) { System.out.println(”null”); } else (str.length() == 0) { System.out.println(”zero”); } else { System.out.println(”some”); } } What is the result?()
第7题:
public class Yippee2{ stati cpublic void main(String[]yahoo){ for(intx=1;x
第8题:
public class TestString 1 { public static void main(String[] args) { String str = “420”; str += 42; System.out.print(str); } } What is the output?()
第9题:
public class Test { public enum Dogs {collie, harrier, shepherd}; public static void main(String [] args) { Dogs myDog = Dogs.shepherd; switch (myDog) { case collie: System.out.print(”collie “); case default: System.out.print(”retriever “); case harrier: System.out.print(”harrier “); } } } What is the result?()
第10题:
public class Test { public static void main(String[] args) { String str = NULL; System.out.println(str); } } What is the result?()