单选题public class AssertStuff { public static void main(String [] args) { int x= 5; int y= 7; assert (x y): “stuff”; System.out.println(”passed”); } } And these command line invocations:java AssertStuff java -ea AssertStuff What is the result?()A passed stuffB stuff passedC passed An AssertionError is thrown with the word “stuff” added to the stack trace.D passed An AssertionError is thrown without the word “stuff” added to the stack trace.E passed An AssertionException is thrown with the word “stuff” added to the stack trace.F passed An AssertionException is thrown without the word “stuff” added to the stack trace.
单选题
public class AssertStuff { public static void main(String [] args) { int x= 5; int y= 7; assert (x> y): “stuff”; System.out.println(”passed”); } } And these command line invocations:java AssertStuff java -ea AssertStuff What is the result?()
A
passed stuff
B
stuff passed
C
passed An AssertionError is thrown with the word “stuff” added to the stack trace.
D
passed An AssertionError is thrown without the word “stuff” added to the stack trace.
E
passed An AssertionException is thrown with the word “stuff” added to the stack trace.
F
passed An AssertionException is thrown without the word “stuff” added to the stack trace.
参考解析
解析:
暂无解析
相关考题:
执行下面程序,显示的结果为( )。 public class Test { public static void main (String args[]) { Test t=newTest(); System.out.println (Loverload ("2","3")); } int overload (intx,int y) {return x+y;} String overload (String x,Stnng y){return x+y;} }A.2B.3C.5D.23
public class AssertStuff { public static void main(String [] args) { int x= 5; int y= 7; assert (x y): “stuff”; System.out.println(”passed”); } } And these command line invocations:java AssertStuff java -ea AssertStuff What is the result?()A、 passed stuffB、 stuff passedC、 passed An AssertionError is thrown with the word “stuff” added to the stack trace.D、 passed An AssertionError is thrown without the word “stuff” added to the stack trace.E、 passed An AssertionException is thrown with the word “stuff” added to the stack trace.F、 passed An AssertionException is thrown without the word “stuff” added to the stack trace.
class DemoApp{ public static void main(String[] args){ int x = 5; int y = ++x + x++; S ystem.out.println(“y=”+y+”,x=”+x); } } 以上程序运行后的输出结果是哪项?() A、y=10,x=5B、y=11,x=6C、y=12,x=7D、y=11,x=7
public class Yippee2 { static public void main(String [] yahoo) { for(int x= 1; xSystem.out.print(yahoo[x] + “ “); } } } and the command line invocation: java Yippee2 a b c What is the result?() A、a bB、b cC、a b cD、 Compilation fails.E、 An exception is thrown at runtime.
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?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 doStuffx = 6 main x = 6D、 doStuffx = 6 main x = 7E、 doStuffx = 7 main x = 6F、 doStuffx = 7 main x = 7
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?() A、 baz =B、 baz = nullC、 baz = blueD、 Compilation fails.E、 An exception is thrown at runtime.
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?() A、 No output is produced. 123B、 No output is produced. 234C、 No output is produced. 1234D、 An exception is thrown at runtime. 123E、 An exception is thrown at runtime. 234F、 An exception is thrown at rijntime. 1234
现有: 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 结果为:() A、 3B、 5C、 编译失败D、 运行时异常被抛出
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); } } 结果为:() A、1B、2C、3D、编译失败
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 结果为:()A、 3B、 5C、 编译失败D、 运行时异常被抛出
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?() A、 int LongB、 Short LongC、 Compilation fails.D、 An exception is thrown at runtime.
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?() A、 finishedB、 Compilation fails.C、 An AssertionError is thrown and finished is output.D、 An AssertionError is thrown with the message “assertion failed”.E、 An AssertionError is thrown with the message “assertion passed”.
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?() A、 The output is “Equal”B、 The output in “Not Equal”C、 An error at line 5 causes compilation to fall.D、 The program executes but does not print a message.
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?() A、 short LONGB、 SHORT LONGC、 Compilation fails.D、 An exception is thrown at runtime.
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?() A、 finishedB、 Compilation fails.C、 An AssertionError is thrown.D、 An AssertionError is thrown and finished is output.
单选题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?()A No output is produced. 123B No output is produced. 234C No output is produced. 1234D An exception is thrown at runtime. 123E An exception is thrown at runtime. 234F An exception is thrown at rijntime. 1234
单选题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?()A The output is “Equal”B The output in “Not Equal”C An error at line 5 causes compilation to fall.D The program executes but does not print a message.
单选题现有: 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 结果为:()A 3B 5C 编译失败D 运行时异常被抛出
单选题现有: 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 结果为:()A 3B 5C 编译失败D 运行时异常被抛出
单选题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?()A int LongB Short LongC Compilation fails.D An exception is thrown at runtime.
单选题public class WhileFoo { public static void main (String []args) { int x= 1, y = 6; while (y--) {x--;} system.out.printIn(“x=” + x “y =” + y); } } What is the result?()A The output is x = 6 y = 0B The output is x = 7 y = 0C The output is x = 6 y = -1D The output is x = 7 y = -1E Compilation will fail.
单选题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?()A finishedB Compilation fails.C An AssertionError is thrown and finished is output.D An AssertionError is thrown with the message “assertion failed”.E An AssertionError is thrown with the message “assertion passed”.
单选题class Foo { public static void main(String [] args) { int x = 0; int y = 4; for(int z=0; z 〈 3; z++, x++) { if(x 〉 1 ++y 〈 10) y++; } System.out.println(y); } } 结果是什么?()A6B7C8D10
单选题public class Yippee2 { static public void main(String [] yahoo) { for(int x= 1; xSystem.out.print(yahoo[x] + “ “); } } } and the command line invocation: java Yippee2 a b c What is the result?()Aa bBb cCa b cD Compilation fails.E An exception is thrown at runtime.
单选题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); } } 结果为:()A1B2C3D编译失败
单选题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?()A short LONGB SHORT LONGC Compilation fails.D An exception is thrown at runtime.
单选题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?()A finishedB Compilation fails.C An AssertionError is thrown.D An AssertionError is thrown and finished is output.