passed stuff
stuff passed
passed An AssertionError is thrown with the word “stuff” added to the stack trace.
passed An AssertionError is thrown without the word “stuff” added to the stack trace.
passed An AssertionException is thrown with the word “stuff” added to the stack trace.
passed An AssertionException is thrown without the word “stuff” added to the stack trace.
第1题:
Given the command line java Pass2 and: public class Pass2 { public void main(String [] args) { int x=6; Pass2 p = new Pass2(); p.doStuff(x); System.out.print(” main x = “+ x); } void doStuff(int x) { System.out.print(” doStuffx = “+ x++); } } What is the result?()
第2题:
public class Yippee { public static void main(String [] args) { for(int x = 1; x < args.length; x++) { System.out.print(args[x] +“ “); } } } and two separate command line invocations: java Yippee java Yippee 1234 What is the result?()
第3题:
class Top { static int x = 1; public Top(int y) { x *= 3; } } class Middle extends Top { public Middle() { x += 1; } public static void main(String [] args) { Middle m = new Middle(); System.out.println(x); } } 结果为:()
第4题:
public class Yikes { public static void go(Long n) {System.out.println(”Long “);} public static void go(Short n) {System.out.println(”Short “);} public static void go(int n) {System.out.println(”int “);} public static void main(String [] args) { short y= 6; long z= 7; go(y); go(z); } } What is the result?()
第5题:
public class IfTest ( public static void main(string[]args) { int x = 3; int y = 1; if (x = y) system.out.printIn(“Not equal”); else system.out.printIn(“Equal”); } ) What is the result?()
第6题:
public class Test { public static void main(String[] args) { int x = 0; assert (x > 0): “assertion failed”; System.out.println(“finished”); } } What is the result?()
第7题:
The output is “Equal”
The output in “Not Equal”
An error at line 5 causes compilation to fall.
The program executes but does not print a message.
第8题:
3
5
编译失败
运行时异常被抛出
第9题:
The output is x = 6 y = 0
The output is x = 7 y = 0
The output is x = 6 y = -1
The output is x = 7 y = -1
Compilation will fail.
第10题:
6
7
8
10
第11题:
1
2
3
编译失败
第12题:
finished
Compilation fails.
An AssertionError is thrown.
An AssertionError is thrown and finished is output.
第13题:
public class Test { public static void main( String[] args) { String foo = args[1]; String bar = args[2]; String baz = args[3]; System.out.println(“baz = “ + baz); } } And the command line invocation: java Test red green blue What is the result?()
第14题:
现有: class TestMain { static int x = 2; static { x = 4; } public static void main(String... args) { int y = x + 1; System.out.println(y); } } 和命令行: java TestMain 结果为:()
第15题:
class TestMain { static int x = 2; static { x = 4; } static public void main(String[] args) { int y = x + 1; System.out.println(y); } } 和命令行: java TestMain 结果为:()
第16题:
public class Test { public static void main(String[] args) { int x = 0; assert (x > 0) ? “assertion failed” : “assertion passed”; System.out.println(“Finished”); } } What is the result?()
第17题:
public class Wow { public static void go(short n) {System.out.println(”short”); } public static void go(Short n) {System.out.println(”SHORT”);} public static void go(Long n) {System.out.println(” LONG”); } public static void main(String [] args) { Short y= 6; int z=7; go(y); go(z); } } What is the result?()
第18题:
No output is produced. 123
No output is produced. 234
No output is produced. 1234
An exception is thrown at runtime. 123
An exception is thrown at runtime. 234
An exception is thrown at rijntime. 1234
第19题:
3
5
编译失败
运行时异常被抛出
第20题:
int Long
Short Long
Compilation fails.
An exception is thrown at runtime.
第21题:
finished
Compilation fails.
An AssertionError is thrown and finished is output.
An AssertionError is thrown with the message “assertion failed”.
An AssertionError is thrown with the message “assertion passed”.
第22题:
a b
b c
a b c
Compilation fails.
An exception is thrown at runtime.
第23题:
short LONG
SHORT LONG
Compilation fails.
An exception is thrown at runtime.