欢迎来到天天文库
浏览记录
ID:38582289
大小:93.50 KB
页数:27页
时间:2019-06-15
《SCJP模拟题 AND Answer [1]》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Question1:Whichofthefollowingclassdefinitionsdefinesalegalabstractclass?Selectallrightanswers.a)classAnimal{abstractvoidgrowl();}b)abstractAnimal{abstractvoidgrowl();}c)classabstractAnimal{abstractvoidgrowl();}d)abstractclassAnimal{abstractvoidgrowl();}e)abstractclassAnimal{abstractvoid
2、growl(){System.out.println("growl");}}Question2:ForanobjecttobeatargetforaThread,thatobjectmustbeoftype:Fillintheblank.Question3:WhatistheproperwayofdefiningaclassnamedKeysothatitcannotbesubclassed?a)classKey{}b)abstractfinalclassKey{}c)nativeclassKey{}d)classKey{final;}e)finalclassKey{
3、}Question4:WhatmodesarelegalforcreatinganewRandomAccessFileobject?Selectallvalidanswers.a)"w"b)"r"c)"x”d)"rw"e)"xrw"Question5:Giventhefollowingcode:classTester{publicstaticvoidmain(String[]args){CellPhonecell=newCellPhone();cell.emergency();}}classPhone{finalvoiddial911(){//codetodial91
4、1here...}}classCellPhoneextendsPhone{voidemergency(){dial911();}}WhatwillhappenwhenyoutrytocompileandruntheTesterclass?a)ThecodewillnotcompilebecausePhoneisnotalsodeclaredasfinal.b)Thecodewillnotcompilebecauseyoucannotinvokeafinalmethodfromasubclass.c)Thecodewillcompileandrunfine.d)Thec
5、odewillcompilebutwillthrowaNoSuchMethodExceptionwhenTesterisrun.e)PhoneandCellPhonearefine,butTesterwillnotcompilebecauseitcannotcreateaninstanceofaclassthatderivesfromaclassdefiningafinalmethod.Question6:Whichassignmentsarelegal?Selectallvalidanswers.a)longtest=012;b)floatf=-412;c)into
6、ther=(int)true;d)doubled=0x12345678;e)shorts=10;Question7:Giventhisclassdefinitions:abstractclassTransactionimplementsRunnable{}classDepositextendsTransaction{protectedvoidprocess(){addAmount();}voidundo(inti){System.out.println("Undo");}}Whatwillhappenifweattemptedtocompilethecode?Sele
7、cttheonerightanswer.a)Thiscodewillnotcompilebecausetheparameteriisnotusedinundo().b)Thiscodewillnotcompilebecausethereisnomain()method.c)ThiscodewillnotcompilebecauseDepositmustbeanabstractclass.d)ThiscodewillnotcompilebecauseDepositisnotdeclaredpublic.e)Everythingwillcompilefi
此文档下载收益归作者所有