SCJP认证试题及答案.docx
- 文档编号:1330475
- 上传时间:2022-10-20
- 格式:DOCX
- 页数:25
- 大小:24.32KB
SCJP认证试题及答案.docx
《SCJP认证试题及答案.docx》由会员分享,可在线阅读,更多相关《SCJP认证试题及答案.docx(25页珍藏版)》请在冰豆网上搜索。
SCJP认证试题及答案
转载对题目和答案谨做参考
Q1
Amethodis...
1)animplementationofanabstraction.
2)anattributedefiningthepropertyofaparticularabstraction.
3)acategoryofobjects.
4)anoperationdefiningthebehaviorforaparticularabstraction.
5)ablueprintformakingoperations.
Q2
Anobjectis...
1)whatclassesareinstantiatedfrom.
2)aninstanceofaclass.
3)ablueprintforcreatingconcreterealizationofabstractions.
4)areferencetoanattribute.
5)avariable.
Q3
Whichlinecontainsaconstructorinthisclassdefinition?
publicclassCounter{//
(1)
intcurrent,step;
publicCounter(intstartValue,intstepValue){//
(2)
set(startValue);
setStepValue(stepValue);
}
publicintget(){returncurrent;}//(3)
publicvoidset(intvalue){current=value;}//(4)
publicvoidsetStepValue(intstepValue){step=stepValue;}//(5)
}
1)Codemarkedwith
(1)isaconstructor
2)Codemarkedwith
(2)isaconstructor
3)Codemarkedwith(3)isaconstructor
4)Codemarkedwith(4)isaconstructor
5)Codemarkedwith(5)isaConstructor
Q4
GiventhatThingisaclass,howmanyobjectsandreferencevariablesarecreatedbythefollowingcode?
Thingitem,stuff;
item=newThing();
Thingentity=newThing();
1)Oneobjectiscreated
2)Twoobjectsarecreated
3)Threeobjectsarecreated
4)Onereferencevariableiscreated
5)Tworeferencevariablesarecreated
6)Threereferencevariablesarecreated.
Q5
Aninstancemember…
1)isalsocalledastaticmember
2)isalwaysavariable
3)isneveramethod
4)belongstoasingleinstance,nottotheclassasawhole
5)alwaysrepresentsanoperation
Q6
HowdoobjectspassmessagesinJava?
1)Theypassmessagesbymodifyingeachother'smembervariables
2)Theypassmessagesbymodifyingthestaticmembervariablesofeachother'sclasses
3)Theypassmessagesbycallingeachother'sinstancemembermethods
4)Theypassmessagesbycallingstaticmembermethodsofeachother'sclasses.
Q7
Giventhefollowingcode,whichstatementsaretrue?
classA{
intvalue1;
}
classBextendsA{
intvalue2;
}
1)ClassAextendsclassB.
2)ClassBisthesuperclassofclassA.
3)ClassAinheritsfromclassB.
4)ClassBisasubclassofclassA.
5)ObjectsofclassAhaveamembervariablenamedvalue2.
Q8
IfthissourcecodeiscontainedinafilecalledSmallProg.java,whatcommandshouldbeusedtocompileitusingtheJDK?
publicclassSmallProg{
publicstaticvoidmain(Stringargs[]){System.out.println("Goodluck!
");}
}
1)javaSmallProg
2)avacSmallProg
3)javaSmallProg.java
4)javacSmallProg.java
5)javaSmallProgmain
Q9
Giventhefollowingclass,whichstatementscanbeinsertedatposition1withoutcausingthecodetofailcompilation?
publicclassQ6db8{
inta;
intb=0;
staticintc;
publicvoidm(){
intd;
inte=0;
//Position1
}
}
1)a++;
2)b++;
3)c++;
4)d++;
5)e++;
Q10
Whichstatementsaretrueconcerningtheeffectofthe>>and>>>operators?
1)Fornon-negativevaluesoftheleftoperand,the>>and>>>operatorswillhavethesameeffect.
2)Theresultof(-1>>1)is0.
3)Theresultof(-1>>>1)is-1.
4)Thevaluereturnedby>>>willneverbenegativeaslongasthevalueoftherightoperandisequaltoorgreaterthan1.
5)Whenusingthe>>operator,theleftmostbitofthebitrepresentationoftheresultingvaluewillalwaysbethesamebitvalueastheleftmostbitofthebitrepresentationoftheleftoperand.
Q11
Whatiswrongwiththefollowingcode?
classMyExceptionextendsException{}
publicclassQb4ab{
publicvoidfoo(){
try{
bar();
}finally{
baz();
}catch(MyExceptione){}
}
publicvoidbar()throwsMyException{
thrownewMyException();
}
publicvoidbaz()throwsRuntimeException{
thrownewRuntimeException();
}
}
1)Sincethemethodfoo()doesnotcatchtheexceptiongeneratedbythemethodbaz(),itmustdeclaretheRuntimeExceptioninitsthrowsclause.
2)Atryblockcannotbefollowedbybothacatchandafinallyblock.
3)Anemptycatchblockisnotallowed.
4)Acatchblockcannotfollowafinallyblock.
5)Afinallyblockmustalwaysfollowoneormorecatchblocks.
Q12
Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?
publicclassQd803{
publicstaticvoidmain(Stringargs[]){
Stringword="restructure";
System.out.println(word.substring(2,3));
}
}
1)est
2)es
3)str
4)st
5)s
Q13
GiventhatastaticmethoddoIt()inaclassWorkrepresentsworktobedone,whatblockofcodewillsucceedinstartinganewthreadthatwilldothework?
CODEBLOCKA:
Runnabler=newRunnable(){
publicvoidrun(){
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- SCJP 认证 试题 答案
![提示](https://static.bdocx.com/images/bang_tan.gif)