Java认证考试综合练习

单选题现有:  class  Parser extends  Utilis  {  public static void main (String  []  args)  {  try  {  System. out.print (new  Parser ( ) .getlnt ("42")} ;     }  catch (NumberFormatException n) {  System.out .println ( "NFExc" ) ;   }     }  int getlnt (String

题目
单选题
现有:  class  Parser extends  Utilis  {  public static void main (String  []  args)  {  try  {  System. out.print (new  Parser ( ) .getlnt ("42")} ;     }  catch (NumberFormatException n) {  System.out .println ( "NFExc" ) ;   }     }  int getlnt (String arg)  throws NumberFormatException{    return Integer.parselnt (arg) ;     }     class Utils {  int getlnt (String arg)  {  return 42;  }    }  结果为 :()
A

 NFExc

B

 42

C

 42NFExc

D

编译失败

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

第1题:

使下列程序正常运行并且输出“Hello!”,横线处应填写的内容是( )。 class Test { public static void main(string[]args){ Test t=new Test; start; } Public void run{ System.out.println("Hello!¨); )

A.extends Thread

B.extends Float

C.extends Iostream

D.extends Stdio


正确答案:A
A。【解析】从后面重写了run方法来看,这是通过继承Thread类,并重写run方法定义线程体,然后创建该子类的对象的方式来创建线程。

第2题:

class One {  public One() { System.out.print(1); }  }  class Two extends One {  public Two() { System.out.print(2); }  }  class Three extends Two {  public Three() { System.out.print(3); }  }  public class Numbers{  public static void main( String[] argv) { new Three(); }  }  What is the result when this code is executed?() 

  • A、 1
  • B、 3
  • C、 123
  • D、 321
  • E、 The code rims with no output.

正确答案:C

第3题:

下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new Te

A.0

B.1

C.2

D.3


正确答案:C

第4题:

现有:  interface Data {public void load();}  abstract class Info {public abstract void load();}      下列类定义中正确使用Data和Info的是哪项?() 

  • A、 public class Employee implements Info extends Data { public void load(){/*dosomething*/}     }
  • B、public class Employee extends Inf.implements Data{ public void load() {/*do something*/}     }
  • C、public class Empl.yee implements Inf extends Data{ public void Data.1oad(){* do something*/}     public void load(){/*do something*/}     }
  • D、public class Employee extends Inf implements Data  {  public void Data.1oad()  {/*do something*/)     public void info.1oad(){/*do something*/}    }

正确答案:B

第5题:

interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?() 

  • A、 public class Employee extends Info implements Data { public void load() { /*do something*/ } }
  • B、 public class Employee implements Info extends Data { public void load() { /*do something*/ } }
  • C、 public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
  • D、 public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
  • E、 public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
  • F、 public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }

正确答案:A

第6题:

编程题:

Class father{fathe() {}

Class sun extends father

{ son() {…..}

Public static void main()

{ son a=new father();

}

}

此程序是否正确,为什么?


正确答案:
 

第7题:

public class TestA{    public void methodA() throws IOException{        //……    } }  public class TestB extends TestA{    public void methodA() throws EOFException{        //……   } }  public class TestC extends TestA{    public void methodA() throws Exception{        //……   } }  当编译类TestC的时候,结果是哪项?() 

  • A、 正常
  • B、 编译错误
  • C、 运行错误
  • D、 以上都不对

正确答案:B

第8题:

interface A{

int x = 0;

}

class B{

int x =1;

}

class C extends B implements A {

public void pX(){

System.out.println(x);

}

public static void main(String[] args) {

new C().pX();

}

}


正确答案:

 

错误。在编译时会发生错误(错误描述不同的JVM 有不同的信息,意思就是未明确的

x 调用,两个x 都匹配(就象在同时import java.util 和java.sql 两个包时直接声明Date 一样)。

对于父类的变量,可以用super.x 来明确,而接口的属性默认隐含为 public static final.所以可

以通过A.x 来明确。

第9题:

class TestA {  public void start() { System.out.println(”TestA”); }  }  public class TestB extends TestA {  public void start() { System.out.println(”TestB”); } public static void main(String[] args) {  ((TestA)new TestB()).start();  }  }  What is the result?() 

  • A、 TestA
  • B、 TestB
  • C、 Compilation fails.
  • D、 An exception is thrown at runtime.

正确答案:B

第10题:

现有:  class  Parser extends  Utilis  {  public static void main (String  []  args)  {  try  {  System. out.print (new  Parser ( ) .getlnt ("42")} ;     }  catch (NumberFormatException n) {  System.out .println ( "NFExc" ) ;   }     }  int getlnt (String arg)  throws NumberFormatException{    return Integer.parselnt (arg) ;     }     class Utils {  int getlnt (String arg)  {  return 42;  }    }  结果为 :()

  • A、 NFExc
  • B、 42
  • C、 42NFExc
  • D、编译失败

正确答案:B

更多相关问题