单选题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  p

题目
单选题
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.

参考答案和解析
正确答案: A
解析: 暂无解析
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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=5
  • B、y=11,x=6
  • C、y=12,x=7
  • D、y=11,x=7

正确答案:C

第2题:

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 = 6
  • D、 doStuffx = 6 main x = 7
  • E、 doStuffx = 7 main x = 6
  • F、 doStuffx = 7 main x = 7

正确答案:B

第3题:

执行下面程序,显示的结果为( )。 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.2

B.3

C.5

D.23


正确答案:D
解析:本题考查方法重载相关知识。方法的重载是指多个方法可以享用相同的名字,但参数的数量或类型必须不完全相同、即方法体有昕不同。使用该方法时,编译系统会根据实参类型选择执行相应的方法。本题中,在调用overload()方法时,实参为字符串,因此会调用String overload (String x,String y)方法,该方法返回两实参连接后的结果,所以返回值为“23”。

第4题:

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、1
  • B、2
  • C、3
  • D、编译失败

正确答案:D

第5题:

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. 123
  • B、 No output is produced. 234
  • C、 No output is produced. 1234
  • D、 An exception is thrown at runtime. 123
  • E、 An exception is thrown at runtime. 234
  • F、 An exception is thrown at rijntime. 1234

正确答案:B

第6题:

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 b
  • B、b c
  • C、a b c
  • D、 Compilation fails.
  • E、 An exception is thrown at runtime.

正确答案:B

第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 = null
  • C、 baz = blue
  • D、 Compilation fails.
  • E、 An exception is thrown at runtime.

正确答案:E

第8题:

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.

正确答案:C

第9题:

现有:  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、 3
  • B、 5
  • C、 编译失败
  • D、 运行时异常被抛出

正确答案:B

第10题:

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、 3
  • B、 5
  • C、 编译失败
  • D、 运行时异常被抛出

正确答案:B

更多相关问题