java程序员认证试题练习_第1页
java程序员认证试题练习_第2页
java程序员认证试题练习_第3页
java程序员认证试题练习_第4页
java程序员认证试题练习_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

本文格式为Word版,下载可任意编辑——java程序员认证试题练习java程序员认证试题练习

人生像攀登一座山,而找寻出路,却是一种学习的过程,我们应当在这过程中,学习稳定冷静,学习如何从慌乱中找到活力。以下是我为大家探寻整理的java程序员认证试题练习,梦想能给大家带来扶助!更多精彩内容请实时关注我们我!

一.说明:真实考试

1.考试形式:网络计算机

2.考题形式:多项选择,单项选择,简答

3.题量:60

4.考试时间:120分钟

二.模拟题

1.Whichstatementaboutthegarbagecollectionmechanismaretrue?

A.Garbagecollectionrequireadditionalprogramecodeincaseswheremultiplethreadsarerunning.

B.Theprogrammercanindicatethatareferencethroughalocalvariableisnolongerofinterest.

C.TheprogrammerhasamechanismthatexplicityandimmediatelyfreesthememoryusedbyJavaobjects.

D.ThegarbagecollectionmechanismcanfreethememoryusedbyJavaObjectatexplectiontime.

E.Thegarbagecollectionsystemneverreclaimsmemoryfromobjectswhilearestillaccessibletorunninguserthreads.

2.Givethefollowingmethod:

1publicvoidmethod

2Stringa,b;

3a=newString“helloworld”;

4b=newString“gameover”;

5System.out.printlnab”ok”;

6a=null;

7a=b;

8System.out.printlna;

9

Intheabsenceofcompileroptimization,whichistheearliestpointtheobjectareferedisdefinitelyelibiletobegarbagecollection.

A.beforeline3

B.beforeline5

C.beforeline6

D.beforeline7

E.Beforeline9

3.Intheclassjava.awt.AWTEvent,whichistheparentclassuponwhichjdk1.1awteventsarebasedthereisamethodcalledgetIDwhichphraseaccuratelydescribesthereturnvalueofthismethod?

A.Itisareferencetotheobjectdirectlyaffectedbythecauseoftheevent.

B.Itisanindicationofthenatureofthecauseoftheevent.

C.Itisanindicationofthepositionofthemousewhenitcausedtheevent.

D.Inthecaseofamouseclick,itisanindicationofthetextunderthemouseatthetimeoftheevent.

E.Ittellsthestateofcertainkeysonthekeybordatthetimeoftheevent.

F.Itisanindicationofthetimeatwhichtheeventoccurred.

4.Whichstatementaboutlisteneristrue?

A.Mostcomponentallowmultiplelistenerstobeadded.

B.Ifmultiplelistenerbeaddtoasinglecomponent,theeventonlyaffectedonelistener.

C.Componentdon?tallowmultiplelistenerstobeadd.

D.ThelistenermechanismallowsyoutocallanaddXxxxListenermethodasmanytimesasisneeded,specifyingasmanydifferentlistenersasyourdesignrequire.

5.Givethefollowingcode:

publicclassExample

publicstaticvoidmainStringargs[]

intl=0;

do

System.out.println“Doingitforlis:”l;

while--l0

System.out.println“Finish”;

Whichwellbeoutput:

A.Doingitforlis3

B.Doingitforlis1

C.Doingitforlis2

D.Doingitforlis0

E.Doingitforlis?C1

F.Finish见1-5题答案

答案及细致分析:

1。B、E

JAVA的垃圾回收机制是通过一个后台系统级线程对内存调配处境举行跟踪实现的,对程序员来说是通明的,程序员没有任何方式使无用内存显示的、立刻的被释放。而且它是在程序运行期间发生的。

答案B报告我们程序员可以使一个本地变量失去任何意义,例如给本地变量赋值为“null”;答案E报告我们在程序运行期间不成能完全释放内存。

2。D

第6行将null赋值给a以后,a以前保存的引用所指向的内存空间就失去了作用,它可能被释放。所以对象a可能最早被垃圾回收是在第7行以前,应选择D选项。

3。B

请查阅JAVA类库。getID方法的返回值是“eventtype”。在认证考试中,总会有类似的书本以外的学识,这只能靠多实践来增长学识了。

4。A、D

控件可以同时使用多个“addXxxxListener”方法参与多个监测器。并且当多个监测器参与到同一控件中时,事情可以响应多个监测器,响应是没有固定依次的。

5。D、F

此题主要考察考生对流程操纵的掌管处境。这是当型循环,条件为真执行,条件为假那么退出。循环体至少执行一次,故会输出D。循环体以外的语句总会被执行,故输出F。

6.Givethecodefragment:

1switchx

2case1:System.out.println“Test1”;break;

3case2:

4case3:System.out.println“Test2”;break;

5default:System.out.println“end”;

6

whichvalueofxwouldcause“Test2”totheoutput:

A.1

B.2

C.3

D.default

7.Giveincompletedmethod:

1

2ifunsafe//dosomething…

3elseifsafe//dotheother…

4

ThemethodunsafewellthroeanIOException,whichcompletesthemethodofdeclarationwhenaddedatlineone?

A.publicIOExceptionmethodName

B.publicvoidmethodName

C.publicvoidmethodNamethrowIOException

D.publicvoidmethodNamethrowsIOException

E.publicvoidmethodNamethrowsException

8.Givethecodefragment:

ifx4

System.out.println“Test1”;

elseifx9

System.out.println“Test2”;

else

System.out.println“Test3”;

Whichrangeofvaluexwouldproduceofoutput“Test2”?

A.x4

B.x4

C.x9

D.None

9.Givethefollowingmethod:

publicvoidexample

try

unsafe;

System.out.println“Test1”;

catchSafeExceptioneSystem.out.println“Test2”;

finallySystem.out.println“Test3”;

System.out.println“Test4”;

Whichwilldisplayifmethodunsaferunnormally?

A.Test1

B.Test2

C.Test3

D.Test4

10.Whichmethodyoudefineasthestartingpointofnewthreadinaclassfromwhichnewthethreadcanbeexcution?

A.publicvoidstart

B.publicvoidrun

C.publicvoidint

D.publicstaticvoidmainStringargs[]

E.publicvoidrunnable

6-10答案:

6。B.C

在开关语句中,标号总是不被当做语句的一片面,标号的作用就是做为条件判断而已,一旦匹配告成,就执行其后的语句,一向遇到break语句为止。包括default语句在内

7。D、F

IOException奇怪类是Exception的子类。根据多态性的定义,IOException对象也可以被认为是Exception类型。还要留神在方法声明中抛出奇怪应用关键字“throws”。

8。D

只有两种处境:大于4时输出“Test1”,小于等于4时输出“Test3”。

9。A、C、D

在正常处境下,打印Test1、Test3、Test4;在产生可捕获奇怪时打印Test2、Test3、Test4;在产生不成捕获奇怪时,打印Test3,然后终止程序。留神finally后面的语句总是被执行。

10。B

线程的执行是从方法“run”开头的,该方法是由系统调用的。程序员手工调用方法start,使线程变为可运行状态。

11.Giventhefollowingclassdefinition:

classA

protectedinti;

Ainti

this.i=i;

whichofthefollowingwouldbeavalidinnerclassforthisclass?

Selectallvalidanswers:

A.classB

B.classBextendsA

C.classBextendsA

BSystem.out.println“i=”i;

D.classB

classA

E.classA

12.Whichmodifiershouldbeappliedtoamethodforthelockofobjectthistobeobtainedpriortoexcutionanyofthemethodbody?

A.synchronized

B.abstract

C.final

D.static

E.public

13.ThefollowingcodeisentirecontentsofafilecalledExample.java,causespreciselyoneerrorduringcompilation:

1classSubClassextendsBaseClass

2

3classBaseClass

4Stringstr;

5publicBaseClass

6System.out.println“ok”;

7publicBaseClassStrings

8str=s;

9publicclassExample

10publicvoidmethod

11SubClasss=newSubClass“hello”;

12BaseClassb=newBaseClass“world”;

13

14

Whichlinewouldbecausetheerror?

A.9B.10C.11D.12

14.Whichstatementiscorrectlydeclareavariableawhichissuitableforreferingtoanarrayof50stringemptyobject?

A.String[]a

B.Stringa[]

C.chara[][]

D.Stringa[50]

F.Objecta[50]

15.Givethefollowingjavasourcefragement:

//pointx

publicclassInteresting

//dosomething

WhichstatementiscorrectlyJavasyntaxatpointx?

A.importjava.awt.*;

B.packagemypackage

C.staticintPI=3.14

D.publicclassMyClass//dootherthing…E.classMyClass//dosomething…11-15答案:

11。A

此题测验内部类及关键字“super”的'用法。内部类不能与外部类同名。另外,当B继承A时,A中的构造函数是带参数的,B中缺省构造函数的函数体为空;而JAVA编译器会为空构造函数体自动添加语句“super;”调用父类构造函数,更进一步是调用父类的参数为空的构造函数。而父类中没有参数为空的构造函数。

12。A

此关键字可以在两个线程同时试图访问某一数据时制止数据毁损。

13。C

当一个类中未显式定义构造函数时,缺省的构造函数是以类名为函数名,参数为空,函数体为空。虽然父类中的某一构造函数有字符串参数s,但是子类继承父类时并不继承构造函数,所以它只能使用缺省构造函数。故在第11行出错。

14。A、B

留神,题中问的是如何正确声明一个一维数组,并非实例化或者初始化数组

15。A、E

X处可以是一个输入,包的定义,类的定义。由于常量或变量的声明只能在类中或方法中,故不能选择C;由于在一个文件中只能有一个public类,故不能选择D。

16.Givethisclassoutline:

classExample

privateintx;

//restofclassbody…

AssumingthatxinvokedbythecodejavaExample,whichstatementcanmadexbedirectlyaccessibleinmainmethodofExample.java?

A.Changeprivateintxtopublicintx

B.changeprivateintxtostaticintx

C.Changeprivateintxtoprotectedintx

D.changeprivateintxtofinalintx

17.thepieceofpreliminaryanalsisworkdescribesaclassthatwillbeusedfrequentlyinmanyunrelatedpartsofaproject

“Thepolygonobjectisadrawable,Apolygonhasvertexinformationstoredinavector,acolor,lengthandwidth.”

WhichDatatypewouldbeused?

A.Vector

B.int

C.String

D.Color

E.Date

18.Aclassdesignrequiresthatamembervariableshouldbeaccessibleonlybysamepackage,whichmodiferwordshouldbeused?

A.protected

B.public

C.nomodifer

D.private

19.Whichdeclaresfornativemethodinajavaclasscorrected?

A.publicnativevoidmethod

B.publicnativevoidmethod;

C.publicnativemethod;

D.publicvoidmethodnative;

E.publicvoidnativemethod;

20.Whichmodifershouldbeappliedtoadeclarationofaclassmembervariableforthevalueofvariabletoremainconstantafterthecreationoftheobject?

16-20答安:

16。B

静态方法除了自己的参数外只能直接访问静态成员。访问非静态成员,务必先实例化本类的一个实例,再用实例名点取。

17。A、B、D

polygon的顶点信息存放在Vector类型的对象内部,color定义为Color,length和width定义为int。

留神,这是考试中常见的题型。

18。C

此题考点是高级访问操纵。请考生查阅高级访问操纵说明表格。

19。B

native关键字指明是对本地方法的调用,在JAVA中是只能访问但不能写的方法,它的位置在访问权限修饰语的后面及返回值的前面。

20。final

定义常量的方法是在变量定义前加final关键字。

21.Whichisthemainmethodreturnofaapplication?

A.String

B.byte

C.char

D.void

22.Whichiscorrectedargumentofmainmethodofapplication?

A.Stringargs

B.Stringar[]

C.Charargs[][]

D.StringBufferarg[]

23.“TheEmployeeobjectisaperson,AnEmployeehasappointmentstoreinavector,ahiredateandanumberofdependent”

shortanswer:useshorteststatementdeclareaclassofEmployee.

24.Givethefollowingclassdefinationinseparatesourcefiles:

pub

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论