Java技术笔试题集(附答案)(基础必备)(3)

2019-03-03 17:53

第 11 页 共 71 页

46、类 Teacher 和 Student 是类 Person 的子类;

Teacher t; Student s;

// t and s are all non-null.

if (t instanceof Person ){ s=(Student)t; }

最后一条语句的结果是:

A.将构造一个Student 对象; B.表达式是合法的;

C.表达式是错误的; D.编译时正确, 但运行时错误。 答:D

47、给出下面代码段(多选)

1、switch (m)

2、{ case 0 :System.out.println(“case 0”); 1. case 1: System.out.println(“case 1”); break; 2. case 2:

3. default : System.out.println(default”); 4. }

下列m 的哪些值将引起 “default ”的输出? A.0 B. 1 C. 2 D. 3

答:CD

48、下列哪些说法是正确的?

A. Java语言只允许单一继承 B. Java语言只允许实现一个接口 C. Java语言不允许同时继承一个类并实现一个接口 D. Java语言的单一继承使得代码更加可靠. 答:AD

49、main方法的返回类型是:

A.int B.Void C.Boolean D.Static E. public 答:BDE

50、给定下列代码:

public void test() { try {

oneMethod();

System.out.println( “condition 1”);

} catch (ArrayIndexOutOfBoundsException e){ System.out.println(“condition 2”); }catch(Exception e){

System.out.println(“condition 3”); }finally{

System.out.println(“finally”); } }

oneMethod 正常运行, 将显示?

A. condition 1 B. condition 2 C. condition 3 D. finally 答:AD

51、下列代码哪几行会出错

1) public void modify() { 2) int I, j, k; 3) I=100;

4) while(I>0){ 5) j=I*2;

Copyright Tarena Corporation,2009.All rights reserved

第 12 页 共 71 页

6) System.out.println(“The value of j is “ +j); 7) k=k+1; 8) I--; 9) } 10) }

A. line 4 B. line 6 C. line 7 D. line 8

答:C

52、对于下列代码

public class Parent {

public int addValue (int a ,int b ){ int s; s = a + b; return s; } }

class Child extends Parent { }

下述哪些方法可以加入类Child?

A . int addValue(int a ,int b){//do something…} B. public void addValue(){//do something…} C. public int addValue(int a ){//do something…}

D. public int addValue( int a, int b )throws MyException {//do something…} 答:B、C

53、请选出下面两个类间关系描述错误的项 a. public interface A {} public class B extends A {} b. public interface A {}

public interface B extends A {} c. public interface A {}

public class B implements A {} d. public class A {}

public class B { protected A a;} 答:A

54、下面正确的是

A)float f = 3.14; //默认为double类型 B)byte i = 225; //默认为int类型 C)log k = 33; D)int p[ ][ ]; 答:C、D

55、下列创建数组的方法正确的是

A)int two Dim[ ][ ] = new int[4][ ]; B)int two Dim[ ][ ] = new int[ ][4]; C)int two Dim[ ][ ] = new int[4][5]; D)char a[ ] = {‘A’, ‘B’}; E)char c[ ] = “ABC” ; 答:A、C、D

56、关于线程设计,下列描述正确的是

A. 线程对象必须实现Runnable接口 B. 启动一个线程直接调用线程对象的run()方法 C. Java提供对多线程同步提供语言级的支持 D. 一个线程可以包含多个进程

Copyright Tarena Corporation,2009.All rights reserved

第 13 页 共 71 页

答:C

57、public class X extends Thread implements Runnable{ public void run(){

System.out.println(\ }

public static void main(String args[]) {

Thread t=new Thread(new X()); t.start(); } }

A 第一行会产生编译错误 B 第六行会产生编译错误 C 第六行会产生运行错误 D 程序会运行和启动 答:D

58、根据线程安全的相关知识,分析以下代码,当调用test方法时i>10时是否会引起死锁? public void test(int i) {

lock(this) { if (i>10) { i--; test(i); } } }

A. 会锁死 B. 不会锁死 答:B

59、欲构造ArrayList类得一个实例,此类继承了List接口,下列哪个方法是正确的:

A ArrayList myList = new Object(); B List myList = new ArrayList(); C ArraylList myList = new List(); D List myList = new List(); 答:B

60、Which of the following are methods of the Runnable interface。 A. run B. start C. yield D. stop 答:A

61、Java网络程序设计中,下列正确的描述是(多选) A. Java网络编程API建立在Socket基础之上 B. Java网络接口只支持TCP以及其上层协议 C. Java网络接口只支持UDP以及其上层协议 D. Java网络接口支持IP以上的所有高层协议 答:AD

62、Java I/O程序设计中,下列描述正确的是

A. OutputStream用于写操作 B. InputStream用于写操作 C. I/O库不支持对文件可读可写API

Copyright Tarena Corporation,2009.All rights reserved

第 14 页 共 71 页

答:A

63、选出对于XML的评论正确的选项___

A. XML是一种语言无关平台无关的自描述语言。

B. 标签实际上包含了元素和属性两部分。用元素来描述有规律的数据,用属性来描述系统数据。 C. XML不可跨平台,不具备扩展性。

D.XML文档中的每一个元素都处在一个名字空间中;如果没有指定的名字空间,缺省的名字空间就是和该元素相关联的名字空间。 答:AD

64、(单选)What compiler switch creates an xml file from the xml comments in the files in an assembly?

A. /text B. /doc C. /xml D. /help 答:A

65、说说下面语句是否有错误,或可能出现的缺陷,并指出错误,或缺陷在哪里? public class MyFile implements Runnable{ public void run(){ while (true){ try{

FileReader fr=new FileReader(new File(\ String line=fr.readLine(); System.out.println(line); }catch(IOException err) { }

Sleep(1000); } }

答: 1.fr.readLine()没有这个方法

2.Sleep(1000)需要用Thread.sleep(1000);

66、判断下列语句是否正确,如果有错误,请指出错误所在? List a = new ArrayList(); a.add(5);

答:错误,默认封装int类型。

67、判断下列语句是否正确,如果有错误,请指出错误所在? void foo(final int []arg){ if (arg.length > 1) arg[0] = 5;

}

答:正确

68、判断下列语句是否正确,如果有错误,请指出错误所在? interface A{

int add(final A a);

}

class B implements A{

long add(final A a){

return this.hashCode() + a.hashCode(); }

}

答:返回值不是long类型

69、指出下面程序的运行结果:

Copyright Tarena Corporation,2009.All rights reserved

第 15 页 共 71 页

class A{

static{

System.out.print(\ }

public A (){

System.out.print(\ } }

class B extends A{ static{

System.out.print(\ }

public B (){

System.out.print(\} }

public class Test{

public static void main(String[] args){ A ab = new B (); ab = new B (); } }

答:abxyxy

70、下列代码的输出结果是什么? public class MyFor {

public static void main (String argv[]){ int i; int j;

outer:for(i=1;i<3;i++) inner:for(j=1;j<3;j++){

if (j==2) continue outer;

System.out .println(\ } } }

答:Value for i=1Value for j=1 Value for i=2Value for j=1

71、查看下面的代码,写出可以使程序正常执行的修改方法 public class MyClass { static String s1; String s2;

public static void main(String args[]) { String s3;

System.out.println(\ System.out.println(\ System.out.println(\ } }

答:删除第8行或者将第6行改为String s3 = \

72、为了显示myStr = 23 这样的结果,写出在控制台输入的命令 public class MyClass {

public static void main(String args[]) {

Copyright Tarena Corporation,2009.All rights reserved


Java技术笔试题集(附答案)(基础必备)(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2010年中考生物一轮复习 - 第十九讲生物的生殖和发育

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: