niusouti.com

单选题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?()Apa

题目
单选题
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 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”相关问题
  • 第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?() 

    • 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

  • 第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?() 

    • 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

  • 第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);  }  }  结果为:() 

    • A、1
    • B、2
    • C、3
    • D、编译失败

    正确答案:D

  • 第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?() 

    • A、 int Long
    • B、 Short Long
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:A

  • 第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?()      

    • 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.

    正确答案:C

  • 第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?()  

    • A、 finished
    • B、 Compilation fails.
    • C、 An AssertionError is thrown.
    • D、 An AssertionError is thrown and finished is output.

    正确答案:A

  • 第7题:

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


    正确答案: A
    解析: 暂无解析

  • 第8题:

    单选题
    现有:   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
    解析: 暂无解析

  • 第9题:

    单选题
    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 = 0

    B

     The output is x = 7 y = 0

    C

     The output is x = 6 y = -1

    D

     The output is x = 7 y = -1

    E

     Compilation will fail.


    正确答案: E
    解析: 暂无解析

  • 第10题:

    单选题
    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);  }  }  结果是什么?()
    A

    6

    B

    7

    C

    8

    D

    10


    正确答案: B
    解析: 暂无解析

  • 第11题:

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

    编译失败


    正确答案: B
    解析: 暂无解析

  • 第12题:

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

     finished

    B

     Compilation fails.

    C

     An AssertionError is thrown.

    D

     An AssertionError is thrown and finished is output.


    正确答案: D
    解析: This question is a bit tricky because it lacks the following information: It should include a statement that says whether or not assertions are enabled. If they are indeed enabled, the 
    correction answer is C. but if they are not, the correct answer is A. Assertions are not enabled by default so if the question is not changed, the most logical answer is A.

  • 第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?()  

    • A、 baz =
    • B、 baz = null
    • C、 baz = blue
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:E

  • 第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   结果为:()  

    • A、 3
    • B、 5
    • C、 编译失败
    • D、 运行时异常被抛出

    正确答案:B

  • 第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   结果为:()

    • A、 3
    • B、 5
    • C、 编译失败
    • D、 运行时异常被抛出

    正确答案:B

  • 第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?()  

    • A、 finished
    • B、 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”.

    正确答案:B

  • 第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?() 

    • A、 short LONG
    • B、 SHORT LONG
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:C

  • 第18题:

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


    正确答案: E
    解析: 暂无解析

  • 第19题:

    单选题
    现有:   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

     运行时异常被抛出


    正确答案: A
    解析: 暂无解析

  • 第20题:

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

    B

     Short Long

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: D
    解析: 暂无解析

  • 第21题:

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

     finished

    B

     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”.


    正确答案: E
    解析: 暂无解析

  • 第22题:

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


    正确答案: D
    解析: 暂无解析

  • 第23题:

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

    B

     SHORT LONG

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: A
    解析: 暂无解析