niusouti.com

单选题Given the command line java Pass2 and: What is the result? ()AdoStuff x = 6 main x = 6BCompilation fails.CdoStuff x = 6 main x = 7DAn exception is thrown at runtime.EdoStuff x = 7 main x = 6FdoStuff x = 7 main x = 7

题目
单选题
Given the command line java Pass2 and: What is the result? ()
A

 doStuff x = 6 main x = 6

B

 Compilation fails.

C

 doStuff x = 6 main x = 7

D

 An exception is thrown at runtime.

E

 doStuff x = 7 main x = 6

F

 doStuff x = 7 main x = 7


相似考题
参考答案和解析
正确答案: D
解析: 暂无解析
更多“单选题Given the command line java Pass2 and: What is the result? ()A  doStuff x = 6 main x = 6B  Compilation fails.C  doStuff x = 6 main x = 7D  An exception is thrown at runtime.E  doStuff x = 7 main x = 6F  doStuff x = 7 main x = 7”相关问题
  • 第1题:

    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

  • 第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("mainx="+x); } void doStuff(intx){ 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 mainx =7
    • E、doStuffx=7 mainx =6
    • F、doStuffx=7 mainx =7

    正确答案:B

  • 第3题:

    public class Pass {  public static void main(String [1 args) {  int x 5;  Pass p = new Pass();  p.doStuff(x);  System.out.print(” main x = “+ x);  }  void doStuff(int x) {  System.out.print(” doStuff x = “+ x++);  }  }  What is the result?() 

    • A、 Compilation fails.
    • B、 An exception is thrown at runtime.
    • C、 doStuffx = 6 main x = 6
    • D、 doStuffx = 5 main x = 5
    • E、 doStuffx = 5 main x = 6
    • F、 doStuffx = 6 main x = 5

    正确答案:D

  • 第4题:

    1. class SuperFoo {  2. SuperFoo doStuff(int x) {  3. return new SuperFoo(); 4. }  5. }  6.  7. class Foo extends SuperFoo {  8. //insert code here  9. }   下面哪三项分别插入到第8行,可以编译?()

    • A、int doStuff() { return 42; }
    • B、int doStuff(int x) { return 42; }
    • C、Foo doStuff(int x) { return new Foo(); }
    • D、SuperFoo doStuff(int x) { return new Foo(); }

    正确答案:A,C,D

  • 第5题:

    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

  • 第6题:

    Which two code fragments are most likely to cause a StackOverflowError?()

    • A、int []x = {1,2,3,4,5};for(int y = 0; y < 6; y++)    System.out.println(x[y]);
    • B、static int[] x = {7,6,5,4};static { x[1] = 8;x[4] = 3; }
    • C、for(int y = 10; y < 10; y++)doStuff(y);
    • D、void doOne(int x) { doTwo(x); }void doTwo(int y) { doThree(y); }void doThree(int z) { doTwo(z); }
    • E、for(int x = 0; x < 1000000000; x++) doStuff(x);
    • F、void counter(int i) { counter(++i); }

    正确答案:D,F

  • 第7题:

    单选题
    public class Test {  private static int[] x;  public static void main(String[] args) {  System.out.println(x[0]);  }  }   What is the result?()
    A

     0

    B

     null

    C

     Compilation fails.

    D

     A NullPointerException is thrown at runtime.

    E

     An ArrayIndexOutOfBoundsException is thrown at runtime.


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

  • 第8题:

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


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

  • 第9题:

    单选题
    Given the command line java Pass2 and: What is the result? ()
    A

     doStuff x = 6 main x = 6

    B

     Compilation fails.

    C

     doStuff x = 6 main x = 7

    D

     An exception is thrown at runtime.

    E

     doStuff x = 7 main x = 6

    F

     doStuff x = 7 main x = 7


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

  • 第10题:

    单选题
    现有:  1.class SuperFoo{  2.SuperFoo doStuff (int x)  {      3.return new SuperFoo();      4.    }      5.  }      6.  7. class Foo extends SuperFoo  {     8.    //insert code here     9.  }  和四个声明:   Foo doStuff (int x)  {  return new Foo();  }  Foo doStuff (int x)  {  return new SuperFoo();  }      SuperFoo doStuff(int x)  {  return new Foo();  }  SuperFoo doStuff(int y)  {  return new SuperFoo();  }    分别插入到第8行,有几个可以通过编泽?()
    A

     1

    B

     2

    C

     3

    D

     4


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

  • 第11题:

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

     s 14

    B

     s 16

    C

     s 10

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


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

  • 第12题:

    单选题
    public class Pass{ public static void main(String[]args){ int x=5; Pass p=new Pass(); p.doStuff(x); System.out.print("mainx="+x); } void doStuff(intx){ System.out.print("doStuffx="+x++); } } What is the result?()
    A

    Compilation fails.

    B

    An exception is thrown at runtime.

    C

    doStuff x=6 main x=6

    D

    doStuff x=5 main x=5

    E

    doStuff x=5 main x=6

    F

    doStuff x=6 main x=5


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

  • 第13题:

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

    • A、 s 14
    • B、 s 16
    • C、 s 10
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:D

  • 第14题:

    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

  • 第15题:

    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

  • 第16题:

    public class Test {  private static int[] x;  public static void main(String[] args) {  System.out.println(x[0]);  }  }   What is the result?()   

    • A、 0
    • B、 null
    • C、 Compilation fails.
    • D、 A NullPointerException is thrown at runtime.
    • E、 An ArrayIndexOutOfBoundsException is thrown at runtime.

    正确答案:D

  • 第17题:

    现有:  1.class SuperFoo{  2.SuperFoo doStuff (int x)  {      3.return new SuperFoo();      4.    }      5.  }      6.  7. class Foo extends SuperFoo  {     8.    //insert code here     9.  }  和四个声明:   Foo doStuff (int x)  {  return new Foo();  }  Foo doStuff (int x)  {  return new SuperFoo();  }      SuperFoo doStuff(int x)  {  return new Foo();  }  SuperFoo doStuff(int y)  {  return new SuperFoo();  }    分别插入到第8行,有几个可以通过编泽?()    

    • A、 1
    • B、 2
    • C、 3
    • D、 4

    正确答案:D

  • 第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题:

    单选题
    public class Pass {  public static void main(String [1 args) {  int x 5;  Pass p = new Pass();  p.doStuff(x);  System.out.print(” main x = “+ x);  }  void doStuff(int x) {  System.out.print(” doStuff x = “+ x++);  }  }  What is the result?()
    A

     Compilation fails.

    B

     An exception is thrown at runtime.

    C

     doStuffx = 6 main x = 6

    D

     doStuffx = 5 main x = 5

    E

     doStuffx = 5 main x = 6

    F

     doStuffx = 6 main x = 5


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

  • 第20题:

    单选题
    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("mainx="+x); } void doStuff(intx){ 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 mainx =7

    E

    doStuffx=7 mainx =6

    F

    doStuffx=7 mainx =7


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

  • 第21题:

    单选题
    Given: What is the result?()
    A

    Compilation fails.

    B

    An exception is thrown at runtime.

    C

    doStuff x = 6 main x = 6

    D

    doStuff x = 6 main x = 7

    E

    doStuff x = 7 main x = 6


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

  • 第22题:

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

  • 第23题:

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

  • 第24题:

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