多选题1. class Calc {  2. public static void main(String [] args) {  3. try {  4. int x = Integer.parseInt("42a");  5. //insert code here  6. System.out.print("oops ");  7. }  8. }  9. }  下面哪两行分别插入到第五行,会导致输出“oops”?()A} catch (ClassCastException c) {B} catch 

题目
多选题
1. class Calc {  2. public static void main(String [] args) {  3. try {  4. int x = Integer.parseInt("42a");  5. //insert code here  6. System.out.print("oops ");  7. }  8. }  9. }  下面哪两行分别插入到第五行,会导致输出“oops”?()
A

} catch (ClassCastException c) {

B

} catch (IllegalStateException c) {

C

} catch (NumberFormatException n) {

D

} catch (IllegalArgumentException e) {

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

1. public interface A {  2. public void doSomething(String thing);  3. }  1. public class AImpl implements A {  2. public void doSomething(String msg) { }  3. }  1. public class B {  2. public A doit() {  3. // more code here  4. }  5.  6. public String execute() { 7. // more code here  8. }  9. }  1. public class C extends B {  2. public AImpl doit() {  3. // more code here  4. }  5.  6. public Object execute() {  7. // more code here  8. }  9. }  Which statement is true about the classes and interfaces in the exhibit?() 

  • A、 Compilation will succeed for all classes and interfaces.
  • B、 Compilation of class C will fail because of an error in line 2.
  • C、 Compilation of class C will fail because of an error in line 6.
  • D、 Compilation of class AImpl will fail because of an error in line 2.

正确答案:C

第2题:

现有2 个文件:  1. package x;  2. public class X {  3. public static void doX() { System.out.print("doX "); }  4. }  和:  1. class Find {  2. public static void main(String [] args) {  3. //insert code here  4. }  5. }  哪两行分别插入到类Find 的第3 行将编译并产生输出“doX”? ()

  • A、doX();
  • B、X.doX();
  • C、x.X.doX();
  • D、x.X myX = new x.X(); myX.doX();

正确答案:C,D

第3题:

classCalc{2.publicstaticvoidmain(String[]args){3.try{4.intx=Integer.parseInt("42a");5.//insertcodehere6.System.out.print("oops");7.}8.}9.}下面哪两行分别插入到第五行,会导致输出oops”?()

A.}catch(ClassCastExceptionc){

B.}catch(IllegalStateExceptionc){

C.}catch(NumberFormatExceptionn){

D.}catch(IllegalArgumentExceptione){


参考答案:C, D

第4题:

5. class Order2 implements Runnable {  6. public void run() {  7. for(int x = 0; x 〈 4; x++) {  8. try { Thread.sleep(100); } catch (Exception e) { }  9. System.out.print("r");  10. } }  11. public static void main(String [] args) {  12. Thread t = new Thread(new Order2());  13. t.start();  14. for(int x = 0; x 〈 4; x++) {  15. // insert code here  16. System.out.print("m");  17. } } }  哪一个插入到第15行,最有可能产生输出 rmrmrmrm ?()  

  • A、Thread.sleep(1);
  • B、Thread.sleep(100);
  • C、Thread.sleep(1000);
  • D、try { Thread.sleep(100); } catch (Exception e) { }

正确答案:D

第5题:

现有:   1. class Book {   2. private final void read() { System.out.print("book "); }   3. }   4. class Page extends Book {   5. public static void main(String [] args) {   6. // insert code here   7. }   8. private final void read() { System.out.print("page "); }   9. }   和如下三个代码片段( x, y, z ):   x. // just a comment   y. new Page().read();  z. new Book().read();   分别插入到第6行,有几个允许代码通过编译并可以运行且无异常?() 

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

正确答案:C

第6题:

现有:   1.  class HorseRadish {   2.    // insert code here   3.    protected HorseRadish(int x) {    4.      System.out.println("bok choy");  5.    }  6.  }   7.  class Wasabi extends HorseRadish {   8.    public static void main(String [] args) {   9.      Wasabi w = new Wasabi();  10.   }    11. }   分别插入到第 2 行,哪两项允许代码编译并产生"bok choy" 输出结果?() 

  • A、 // just a comment
  • B、 protected HorseRadish() { }
  • C、 protected HorseRadish() { this(42);}
  • D、 protected  HorseRadish() { new HorseRadish (42);}

正确答案:C,D

第7题:

1. import java.util.*;  2. class ForInTest {  3. static List list = new ArrayList();  4.  5. static List getList() { return list; }  6.  7. public static void main(String [] args) {  8. list.add("a"); list.add("b"); list.add("c");  9. // insert code here  10. System.out.print(o);  11. }  12. } 第 9 行插入哪一项将输出 abc?() 

  • A、for(char o: list)
  • B、for(Object o: getList())
  • C、for(Object o: getList();)
  • D、for(Object o: o.getList())

正确答案:B

第8题:

现有1.classCalc{2.publicstaticvoidmain(String[]args){3.try{4.intx=Integer.parselnt("42a");5.//insertcodehere6.System.out.print("oops");7.}8.}9.}下面哪两行分别插入到第五行,会导致输"oops"?()

A.}catch(IllegalArgumentExceptione){

B.}catch(IllegalStateExceptionc){

C.}catch(NumbelFormatExceptionn){

D.}catch(ClassCastExceptionc){


参考答案:A, C

第9题:

1. class Calc {  2. public static void main(String [] args) {  3. try {  4. int x = Integer.parseInt("42a");  5. //insert code here  6. System.out.print("oops ");  7. }  8. }  9. }  下面哪两行分别插入到第五行,会导致输出“oops”?()

  • A、} catch (ClassCastException c) {
  • B、} catch (IllegalStateException c) {
  • C、} catch (NumberFormatException n) {
  • D、} catch (IllegalArgumentException e) {

正确答案:C,D

第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. }   下面哪三项分别插入到第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

更多相关问题