niusouti.com

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 thro

题目

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
更多“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 throw”相关问题
  • 第1题:

    static void test() throws RuntimeException {  try {  System.out.print(”test “);  throw new RuntimeException();  }  catch (Exception ex) { System.out.print(”exception “); }  }  public static void main(String[] args) {  try { test(); }  catch (RuntimeException ex) { System.out.print(”runtime “); }  System.out.print(”end “);  }  What is the result?() 

    • A、 test end
    • B、 Compilation fails.
    • C、 test runtime end
    • D、 test exception end
    • E、 A Throwable is thrown by main at runtime.

    正确答案:D

  • 第2题:

    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

  • 第3题:

    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“C”);  }  finally {  System.out.print(“B”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new Error();  }  }  What is the result?()  

    • A、 ABCD
    • B、 Compilation fails.
    • C、 C is printed before exiting with an error message.
    • D、 BC is printed before exiting with an error message.
    • E、 BCD is printed before exiting with an error message.

    正确答案:B

  • 第4题:

    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

  • 第5题:

    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

  • 第6题:

    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result? () 

    • A、 AB
    • B、 BC
    • C、 ABC
    • D、 BCD
    • E、 Compilation fails.

    正确答案:D

  • 第7题:

    单选题
    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (RuntimeException ex) {  System.out.print(“B”);  }  catch (Exception ex1) {  System.out.print(“C”);  }   finally {  System.out.print(“D”);  }  System.out.print(“E”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result?()
    A

     BD

    B

     BCD

    C

     BDE

    D

     BCDE

    E

     ABCDE

    F

     Compilation fails.


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

  • 第8题:

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

  • 第9题:

    单选题
    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“C”);  }  finally {  System.out.print(“B”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new Error();  }  }  What is the result?()
    A

     ABCD

    B

     Compilation fails.

    C

     C is printed before exiting with an error message.

    D

     BC is printed before exiting with an error message.

    E

     BCD is printed before exiting with an error message.


    正确答案: E
    解析: The correct answer is : B is printed and then an error message is printed. The exception catch can not catch an Error because this class does not extend Exception but it implements throwable. 

  • 第10题:

    单选题
    public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?()
    A

     Compilation fails.

    B

     An exception is thrown at runtime.

    C

     The code executes normally and prints “bar”.

    D

     The code executes normally, but nothing prints.


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

  • 第11题:

    单选题
    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”); }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }   public static void badMethod() {} }  What is the result?()
    A

     AC

    B

     BD

    C

     ACD

    D

     ABCD

    E

     Compilation fails.


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

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

    public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?() 

    • A、 Compilation fails.
    • B、 An exception is thrown at runtime.
    • C、 The code executes normally and prints “bar”.
    • D、 The code executes normally, but nothing prints.

    正确答案:C

  • 第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("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

  • 第15题:

    static void test() {  try {  String x=null;  System.out.print(x.toString() +“ “);  }  finally { System.out.print(“finally “); }  }  public static void main(String[] args) {  try { test(); }  catch (Exception ex) { System.out.print(”exception “); }  }  What is the result?() 

    • A、 null
    • B、 finally
    • C、 null finally
    • D、 Compilation fails.
    • E、 finally exception

    正确答案:E

  • 第16题:

    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”); }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }   public static void badMethod() {} }  What is the result?()  

    • A、 AC
    • B、 BD
    • C、 ACD
    • D、 ABCD
    • E、 Compilation fails.

    正确答案:C

  • 第17题:

    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (RuntimeException ex) {  System.out.print(“B”);  }  catch (Exception ex1) {  System.out.print(“C”);  }   finally {  System.out.print(“D”);  }  System.out.print(“E”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result?()  

    • A、 BD
    • B、 BCD
    • C、 BDE
    • D、 BCDE
    • E、 ABCDE
    • F、 Compilation fails.

    正确答案:C

  • 第18题:

    static void test() throws Error {  if (true) throw new AssertionError();  System.out.print(”test “);  }  public static void main(String[] args) {  try { test(); }  catch (Exception ex) { System.out.print(”exception “); }  System.out.print(”elld “);  }  What is the result?() 

    • A、 end
    • B、 Compilation fails.
    • C、 exception end
    • D、 exception test end
    • E、 A Throwable is thrown by main.
    • F、 An Exception is thrown by main.

    正确答案:E

  • 第19题:

    单选题
    static void test() {  try {  String x=null;  System.out.print(x.toString() +“ “);  }  finally { System.out.print(“finally “); }  }  public static void main(String[] args) {  try { test(); }  catch (Exception ex) { System.out.print(”exception “); }  }  What is the result?()
    A

     null

    B

     finally

    C

     null finally

    D

     Compilation fails.

    E

     finally exception


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

  • 第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(” 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
    解析: 暂无解析

  • 第21题:

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

  • 第22题:

    单选题
    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result? ()
    A

     AB

    B

     BC

    C

     ABC

    D

     BCD

    E

     Compilation fails.


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

  • 第23题:

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