Java题库175道选择题.docx

上传人:b****7 文档编号:16461464 上传时间:2023-07-13 格式:DOCX 页数:46 大小:57.10KB
下载 相关 举报
Java题库175道选择题.docx_第1页
第1页 / 共46页
Java题库175道选择题.docx_第2页
第2页 / 共46页
Java题库175道选择题.docx_第3页
第3页 / 共46页
Java题库175道选择题.docx_第4页
第4页 / 共46页
Java题库175道选择题.docx_第5页
第5页 / 共46页
Java题库175道选择题.docx_第6页
第6页 / 共46页
Java题库175道选择题.docx_第7页
第7页 / 共46页
Java题库175道选择题.docx_第8页
第8页 / 共46页
Java题库175道选择题.docx_第9页
第9页 / 共46页
Java题库175道选择题.docx_第10页
第10页 / 共46页
Java题库175道选择题.docx_第11页
第11页 / 共46页
Java题库175道选择题.docx_第12页
第12页 / 共46页
Java题库175道选择题.docx_第13页
第13页 / 共46页
Java题库175道选择题.docx_第14页
第14页 / 共46页
Java题库175道选择题.docx_第15页
第15页 / 共46页
Java题库175道选择题.docx_第16页
第16页 / 共46页
Java题库175道选择题.docx_第17页
第17页 / 共46页
Java题库175道选择题.docx_第18页
第18页 / 共46页
Java题库175道选择题.docx_第19页
第19页 / 共46页
Java题库175道选择题.docx_第20页
第20页 / 共46页
亲,该文档总共46页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

Java题库175道选择题.docx

《Java题库175道选择题.docx》由会员分享,可在线阅读,更多相关《Java题库175道选择题.docx(46页珍藏版)》请在冰点文库上搜索。

Java题库175道选择题.docx

Java题库175道选择题

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

B

A、ArrayListmyList=newObject();

B、ListmyList=newArrayList();

C、ArrayListmyList=newList();

D、ListmyList=newList();

2、paint()方法使用哪种类型的参数?

A

A、Graphics

B、Graphics2D

C、String

D、Color

3、指出正确的表达式D

A、byte=128;//byte取值到127

B、Boolean=null;

C、longl=0xfffL;

D、double=0、9239d;

4、指出下列程序运行的结果B

publicclassExample{

Stringstr=newString("good");

char[]ch={'a','b','c'};

publicstaticvoidmain(Stringargs[]){

Exampleex=newExample();

ex、change(ex、str,ex、ch);

System、out、print(ex、str+"and");

Sytem、out、print(ex、ch);

}

publicvoidchange(Stringstr,charch[]){

str="testok";

ch[0]='g';

}

}

A、goodandabc

B、goodandgbc

C、testokandabc

D、testokandgbc

5、运行下列程序,会产生什么结果CDpublicclassXextendsThreadimplementsRunable{

publicvoidrun(){

System、out、println("thisisrun()");

}

publicstaticvoidmain(Stringargs[])

{

Threadt=newThread(newX());

 

t、start();

}

}

A、第一行会产生编译错误

B、第六行会产生编译错误

C、第六行会产生运行错误

D、程序会运行与启动

6、要从文件""文件中读出第10个字节到变量C中,下列哪个方法适合?

A

A、CardLayout

B、FlowLayout

C、BorderLayout

D、GridLayout

8、给出下面代码publicclassPerson{

staticintarr[]=newint[10];

publicstaticvoidmain(Stringa[])

{

System、out、println(arr[1]);

}

}

那个语句就是正确的?

C

A、编译时将产生错误;

B、编译时正确,运行时将产生错误;

C、输出零;

D、输出空。

9、哪个关键字可以对对象加互斥锁?

B

A、transient

Bsynchronized

Cserialize

Dstatic

10、下列哪些语句关于内存回收的说明就是正确的?

B

A、程序员必须创建一个线程来释放内存;

B、内存回收程序负责释放无用内存

C内存回收程序允许程序员直接释放内存

D内存回收程序可以在指定的时间释放内存对象

11、下列代码哪几行会出错:

C

1)publicvoidmodify(){

2)intI,j,k;

3)I=100;

4)while(I>0){

5)j=I*2;

6)System、out、println("Thevalueofjis"+j);

7)k=k+1;

8)I--;

9)}

10}}

A、line4

B、line6

C、line7

100,用简短语句定义这个变量。

D

D、line8

12、MAX_LENGT就是int型public成员变量,变量值保持为常量

A、publicintMAX_LENGTH=100;

B、finalintMAX_LENGTH=100;

C、finalpublicintMAX_LENGTH=100;

D、publicfinalintMAX_LENGTH=100、

13、给出下面代码:

1)classParent{

2}privateStringname;

3}publicParent(){}

4}}

5)publicclassChildextendsParent{

6}privateStringdepartment;

7}publicChild(){}

8}publicStringgetValue(){returnname;}

9}publicstaticvoidmain(Stringarg[]){

10}Parentp=newParent();

11}}

12}}那些行将引起错误?

D

A、第3行

B、第6行

C、第7行

D、第8行

14、类Teacher与Student就是类Person的子类;

Personp;

Teachert;

Students;

//p,tandsareallnon-null、

if(tinstanceofPerson){s=(Student)t;}最后一句语句的结果就是:

BC

A、将构造一个Student对象;

B、表达式就是合法的;

C、表达式就是错误的;

D、编译时正确,但运行时错误。

15、给出下面代码段

1)publicclassTest{

2)intm,n;

3)publicTest(){}

4)publicTest(inta){m=a;}

5)publicstaticvoidmain(Stringarg[]){

6)Testt1,t2;

7)intj,k;

8)j=0;k=0;

9)t1=newTest();

10)t2=newTest(j,k);

11)}

12)}哪行将引起一个编译时错误?

D

A、line3

B、line5

C、line6

D、line10

16、对于下列代码:

1)classPerson{

2)publicvoidprintValue(inti,intj){//...}

3)publicvoidprintValue(inti){//...}

4)}

5)publicclassTeacherextendsPerson{

6)publicvoidprintValue(){//...}

7)publicvoidprintValue(inti){//...}

8)publicstaticvoidmain(Stringargs[]){

9)Persont=newTeacher();

10)t、printValue(10);

11)}

第10行语句将调用哪行语句?

?

D

A、line2

B、line3

C、line6

D、line7

17、哪个关键字可以抛出异常?

C

A、transient

B、finally

C、throw

D、static

18、Main()方法的返回类型就是:

B

A、int

B、void

C、boolean

D、static

19、System类在哪个包中?

D

A、java、util

B、java、io

C、java、awt

D、java、lang

20、对于下列代码:

publicclassParent{

publicintaddValue(inta,intb){ints;

s=a+b;returns;

}

}

classChildextendsParent{

}

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

C

A、intaddValue(inta,intb){//dosomething...}

B、publicvoidaddValue(inta,intb){//dosomething...}

C、publicintaddValue(inta){//dosomething...}

D、publicintaddValue(inta,intb)throwsMyException{//dosomething...}

21、给出下面代码:

publicclasstest{

staticinta[]=newa[10];

publicstaticvoidmain(Stringargs[]){System、out、println(a[10]);

}

}那个选项就是正确的?

A

A、编译时将产生错误;

B、编译时正确,运行时将产生错误;

C、输出零;

D、输出空。

22、下面哪些选项就是正确的main方法说明?

B

A、publicmain(Stringargs[])

B、publicstaticvoidmain(Stringargs[])

C、privatestaticvoidmain(Stringargs[])

D、voidmain()

23、给定下面的代码片段:

C

1)Stringstr=null;

2)if((str!

=null)&&(str、length()>10)){

3)System、out、println("morethan10");

4)}

5)elseif((str!

=null)&(str、length()<5)){

6)System、out、println("lessthan5");

7)}

8)else{System、out、println("end");}

哪些行会导致错误?

A、line1

B、line2

C、line5

D、line8

24、下面哪种注释方法能够支持javadoc命令:

BD

A、/**...**/

B、/*...*/

C、//

D、/**...*/

25、欲编写如下图的一个界面,用于显示用户指定的图像:

如果在区域A中只能放置一个

AWT组件,从各组件的本来功能角度考虑,最好使用哪种组件:

D

A、TextArea

B、Panel

C、Applet

D、Canvas

26、界面如上题所示。

若"Button1"的功能就是:

点击后弹出一个用于输入的界面,获取用户想要显示的

图像文件名,则该界面最好就是(从编程简单与程序不易出错的角度考虑):

c

A、模式(Modal)Dialog

B、非模式(None-modal)Dialog

C、

D、Frame

27、界面如上题所示。

如果在A区域使用某种AWT组件(java、awt、Component的子类)来负责绘制图像则绘图的语句最好应放在该组件的哪个方法中(考虑到应用程序与Java虚拟机的AWT线程都会要求重画该组件)?

B

A、构造方法

B、paint(Graphicsg)

C、update(Graphicsg)

D、repaint()

28、下面关于Applet的说法正确的就是B

A、Applet也需要main方法

B、Applet必须继承自java、awt、Applet

C、Applet能访问本地文件

D、Applet程序不需要编译

29、瞧下面一段程序:

classAclass{

voidgo(){

System、out、println("Aclass");

}

publicclassBclassextendsAclass{

voidgo(){

System、out、println("Bclass");

}

publicstaticvoidmain(Stringargs[]){

Aclassa=newAclass();

Aclassa1=newBclass();

a、go();

a1、go();

}以上程序运行结果就是:

BC

A、Aclass

Aclass

B、Bclass

Bclass

C、Aclass

Bclass

D、Bclass

Aclass

30、下列关于Java线程的说法那些就是正确的()D

A每一个Java线程可以瞧成由代码、一个真实的CPU以及数据三部份组成。

B、创建线程的两种方法中,从Thread类中继承的创建方式可以防止出现多父类问题。

C、Thread类属于java、util程序包。

D、以上说法无一正确。

31、瞧以下程序:

booleana=false;

booleanb=true;

booleanc=(a&&b)&&(!

b);

intresult=(c==false)?

1:

2;

这段程序执行完后,c与result的值就是:

DA

A、c=false;result=1;

B、c=true;result=2;

C、c=true;result=1;

D、c=false;result=2;

32、运行下列程序,会产生什么结果B

publicclassXextendsThreadimplementsRunnable{

publicvoidrun(){

System、out、println("thisisrun()");

}

publicstaticvoidmain(Stringargs[])

{

Threadt=newThread(newX());

t、start();

}

A、intheInnerouter

B、thisisrun()

C、intheInner

D编译不通过

33、指出下列程序的运行结果B

inti=9;

switch(i){

default:

System、out、println("default");

case0:

System、out、println("zero");break;

case1:

System、out、println("one");

case2:

System、out、println("two");

}

A、default

B、default,zero

C、errordefaultclausenotdefined

D、nooutputdisplayed那个

34、运行下列程序,会产生什么结果:

BclassOuter1{privateinta;

voidfoo(doubled,finalfloatf){

Strings;

finalbooleanb;

classInner{

voidmethodInner(){

System、out、println("intheInner");}}

}publicstaticvoidmain(Stringargs[]){

Outer1me=newOuter1();

me、foo(123,123);

System、out、println("outer");

}

}

A、intheInnerouter

B、outer

C、intheInner

D、编译不通过

35、下面哪个单词就是Java语言的关键字(B)

A、FloatB、thisC、stringD、unsigned

36、下面哪个就是Java语言中正确的标识符(C)

A、3comB、importC、thatD、this

37、下面哪个语句不能定义一个字符变量(D)

A、charc1=06477;B、charc2='\uface'

D、charc3=\u0041;

C、charc4=0xbeef;

38、下面哪个修饰符修饰的方法只能被本类中的其她方法使用

A、protected下面哪个运算后结果为32(

39、

B、static

C、

private

D、public

B、(8>>2)<<4

40、下面哪个就是对字符串String

A2A5

C、2>>5

D、

(2<<1)*(32>>3)

A、Strings1=null;

的正确定义(A

B、Strings2='null

 

\uface'

D、Strings4=(String)

C、Strings3=(String)‘abc';

41、下面哪条语句不能定义一个float型的变量(B)

 

A、floatf1=-343;

B、floatf2=3

、14;

 

D、floatf4=2.8F;

C、floatf3=0x12345;

 

42、下面哪条语句定义了5个元素的数组(A)

A、int[]a={22,23,24,25,12};

B、inta[]=newint(5);

C、int[5]array;

D、int[]arr;

43、下面哪个范围就是char型的取值范围(c)

A、-256~255B、-(2A15)~(2A15)-1C、'\u0000

44、给出一段程序,选择运行结果(D)

publicclasssss{

publicstaticvoidmain(Stringargs[])

\uffff

D、

0~3276

 

{

Strings1=args[1];Strings2=args[2];

Strings3=args[3];Strings4=args[4];

System、out、println(“args[2]=”+s2);

}

}

命令行执行:

javasss1234结果就是下面哪一个?

Aargs[2]=2B、args[2]=nullCargs[2]=1D运行出现异常

45、下面哪个描述就是正确的(A)

A、Applet程序中不需要main()方法,也不能有

B、Application程序中可以没有main()方法。

C、Applet程序中可以不定义init()方法

D、Application程序中必须有run()方法

46、给出一段程序,试判断哪个就是正确的结果(B)publicclassrtExcept{

publicstaticvoidthrowit(){

System、out、print(“throwit”);

thrownewRuntimeException();}publicstaticvoidmain(String[]aa){

try{

System、out、print(“hello“);throwit();}

catch(Exceptionre){

System、out、print(“caught”);}finally{

System、out、print(“finally”);}

System、out、print(“after”);

}

}

A、hellothrowitcaught

B、hellothrowitcaughtfinallyafter

C、hellothrowitRuntimeExceptionafter

D、hellothrowitcaughtfinallyafterRuntimeException

则接着会出现

47、对一个java源文件aaa、java,编辑保存后但未编译,在其所在目录下执行javaaaa,什么(C)

A、error:

cannotread:

aaa、java

B、无任何显示

C、Exceptioninthread"main"java、lang、NoClassDefFoundError:

aaa

D程序正常执行并显示

48、编译java程序时出现error:

cannotread:

aaa、java,则下列原因最正确的就是(

A、原因就是执行的当前目录下没有找到aaa、java文件。

B、原因就是没有安装JDK开发环境。

C原因就是java源文件名后缀一定就是以、txt结尾。

D原因就是JDK安装后没有正确设置环境变量PATH与Classpath。

49、给出一段程序,试判断哪个就是正确的结果(D)publicclassmyprogram{

publicstaticvoidmain(Stringargs[]){

try{

System、out、print(“Helloworld”);}

finally{

System、out、println(“Finallyexecuting”);

}

}

}

A、无法编译,因为没有指定异常

B、无法编译,因为没有catch子句

C、Helloworld

D、HelloworldFinallyexecuting

A、3D

B、$this

C、

extends

D、implements

51、下面哪个范围就是char型的取值范围(

A-256〜255B-(2X5)〜(275)-1

下面哪个语句不能定义一个字符变量(

C、'\u0000

\uffff

D、

0〜32767

52、

A、charc1=3210;

B、

charc2=

\uface

C、charc4=0xabcd;

53、下面哪个就是对字符串String的正确定义(A、Strings1=”\n\tnull”;

C、Str

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

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2