java面试题A卷要点.docx

上传人:b****6 文档编号:3033483 上传时间:2022-11-17 格式:DOCX 页数:16 大小:21.55KB
下载 相关 举报
java面试题A卷要点.docx_第1页
第1页 / 共16页
java面试题A卷要点.docx_第2页
第2页 / 共16页
java面试题A卷要点.docx_第3页
第3页 / 共16页
java面试题A卷要点.docx_第4页
第4页 / 共16页
java面试题A卷要点.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

java面试题A卷要点.docx

《java面试题A卷要点.docx》由会员分享,可在线阅读,更多相关《java面试题A卷要点.docx(16页珍藏版)》请在冰豆网上搜索。

java面试题A卷要点.docx

java面试题A卷要点

空间互动笔试题(A)

1.下列数组初始化正确的是:

C

Aint[5]a={1,2,3,4,5};

Bint[2][2]a={{1,2},{3,4}};

Cint[][]a={{2,3,4,5},newint[3]};

Dint[][]a=newint[][5];

2.关于下述程序:

publicclassDivide

{

publicstaticvoidmain(Stringargs[])

{

System.out.println(""17.0/0=""+17.0/0);

System.out.println(""17/0=""+17/0);

}

}

描述正确的是?

C

A.编译出错

B.编译通过,运行时//1、//2处均出现异常

C.编译通过,运行时//1处得到一个无穷大值,//2处将出现异常

D.编译通过,运行时//1处出现异常,//2处将得到一个无穷大值

3.关于下面的类描述中正确的是:

C

classTest{

voidtest(inti){

System.out.println(""Iamanint."");

}

voidtest(Strings){

System.out.println(""Iamastring."");

}

publicstaticvoidmain(Stringargs[]){

Testt=newTest();

charch='y';

t.test(ch);

}

}

A.编译出错

B.编译通过,运行出错

C.编译通过,运行时输出“Iamanint”

D.编译通过,运行时输出“Iamastring”

4.当编译和运行下列程序段时,会发生什么?

C

  classBase{}

  classSubextendsBase{}

  classSub2extendsBase{}

  publicclassCEx{

   publicstaticvoidmain(Stringargv[]){

   Baseb=newBase();

   Subs=(Sub)b;

   }

  }

A通过编译和并正常运行。

B编译时出现错误。

C编译通过,运行时出现异常。

D以上都错

5.下面哪些是java语言中的关键字?

B

Asizeof

Babstract

CNULL

DNative

6.classExSuper{

   Stringname;

   Stringnick_name;

   publicExSuper(Strings,Stringt){

    name=s;

    nick_name=t;

   }

    publicStringtoString(){

     returnname;

    }

   }

   publicclassExampleextendsExSuper{

    publicExample(Strings,Stringt){

    super(s,t);

    }

    publicStringtoString(){

     returnname+""a.k.a""+nick_name;

    }

    publicstaticvoidmain(Stringargs[]){

     ExSupera=newExSuper(""First"",""1st"");

     ExSuperb=newExample(""Second"",""2nd"");

     System.out.println(""ais""+a.toString());

     System.out.println(""bis""+b.toString());

    }

  }

运行结果是C

A编译时会出现例外。

B运行结果为:

        aisFirst

        bissecond

C运行结果为:

        aisFirst

        bisSeconga.k.a2nd

D运行结果为:

        aisFirsta.k.a1nd

        bisSeconda.k.a2nd

7.publicclassFoo{

   publicstaticvoidmain(String[]args){

    try{

      return;}

      finally{System.out.println(""Finally"");

     }

   }

  }

结果是:

D

A程序正常运行,但不输出任何结果。

B程序正常运行,并输出""Finally""。

C编译能通过,但运行时会出现一个例外。

D因为没有catch语句块,所以不能通过编译。

8.package语句正确的是A

A必须在程序开头

B不一定在程序开头

C可以在import之后

D包名可以以数字开头

9.java中,关于char类型错误的是B

A占2字节

B可以存储一个英文字母

C不能存储一个汉字

D其对应的封装类是Character

10.关于内部类错误的是:

A

A静态内部类可以访问其外部类的非静态属性

B非静态内部类可以访问其外部类的静态属性

C内部类可以是protected

D内部类可以是final的

11.Vector与ArrayList正确的是:

C

AArrayList出现比Vector早

BArrayList速度比Vector慢

CArrayList没有同步保护,Vector具有同步保护

DArrayListVector两者都是无序的集合"

12.Whichofthefollowinglinesofcodewillcompilewithouterror?

D

A.

inti=0;

if(i){

System.out.println(“Hi”);

}

B.

booleanb=true;

booleanb2=true;

if(b=b2){

System.out.println(“Sotrue”);

}

C.

inti=1;

intj=2;

if(i==1!

j==2)

System.out.println(“OK”);

D.

inti=1;

intj=2;

if(i==1&|j==2)

System.out.println(“OK”);"

13.下列程序C

classA

{

publicstaticvoidmain(String[]args)

{

Bb=newB();

b.run();

for(inti=0;i<30;i++)

{

System.out.println(""good"");

}

}

}

classBextendsThread

{

publicvoidrun()

{

for(inti=0;i<30;i++)

{

System.out.println(""hello"");

}

}

};

A编译错误

B编译正确,执行时goodhello交替输出

C编译正确,执行时先输出30个hello再输出30个good

D编译正确,程序运行时出现异常

14.FileInputStream和FileOutputStream错误的是C

A是字节流

B是节点流

C用其拷贝文件时,不能拷贝中文

D可以拷贝任何文本文件和2进制文件。

15.一个类中那些内容可以在序列化时写入文件或发送到网络上D

Atransient修饰的属性

B静态属性

C方法

D类名

16.Whathappenswhenyoutrytocompileandrunthefollowingapplication?

Chooseallcorrectoptions.

publicclassZ{

publicstaticvoidmain(String[]args){

newZ();

}

Z(){

Zalias1=this;

Zalias2=this;

synchronized(alias1){

try{

alias2.wait();

System.out.println(“DONEWAITING”);

}

catch(InterruptedExceptione){

System.out.println(“INTERRUPTED”);

}

catch(Exceptione){

System.out.println(“OTHEREXCEPTION”);

}

finally{

System.out.println

(“FINALLY”);

}

}

System.out.println(“ALLDONE”);

}

}

A.Theapplicationcompilesbutdoesn’tprintanything.

B.Theapplicationcompilesandprint“DONEWAITING”

C.Theapplicationcompilesandprint“FINALLY”

D.Theapplicationcompilesandprint“ALLDONE”

E.Theapplicationcompilesandprint“INTERRUPTED”

17.下列关于关系数据库的说法正确的是:

A贮存在列下的数据不必具有相同数据类型。

B行是唯一的(没有完全相同的行)。

C列有顺序。

D行有顺序。

18.以下sql语句正确的是:

Aselectstudentid,depart,count(*)fromstudentgroupbydepart;

Bselectstudentid,count(*)fromstudent;

Cselectdepart,max(avg(age))fromstudentgroupbydepart;

Dselectstudentid,avg(score),max(score)fromscoregroupbystudentid

19.在JSP中使用

getProperty>标记时,不会出现的属性是:

A.name

B.property

C.value

D.以上皆不会出现

20.对于JavaBean的属性,下面哪种说法是不正确的:

AJavaBean中不一定要有属性

BJavaBean类可以不是public的

C要访问和

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1