SCJP模拟试题.docx
- 文档编号:5996164
- 上传时间:2023-01-02
- 格式:DOCX
- 页数:20
- 大小:22.80KB
SCJP模拟试题.docx
《SCJP模拟试题.docx》由会员分享,可在线阅读,更多相关《SCJP模拟试题.docx(20页珍藏版)》请在冰豆网上搜索。
SCJP模拟试题
SCJP模拟试题
QuestionNo:
1
1.Whichstatementaboutthegarbagecollectionmechanismaretrue?
A.Garbagecollectionrequireadditionalprogramecodeincaseswheremultiplethreadsarerunning.
B.Theprogrammercanindicatethatareferencethroughalocalvariableisnolongerofinterest.
C.TheprogrammerhasamechanismthatexplicityandimmediatelyfreesthememoryusedbyJavaobjects.
D.ThegarbagecollectionmechanismcanfreethememoryusedbyJavaObjectatexplectiontime.
E.Thegarbagecollectionsystemneverreclaimsmemoryfromobjectswhilearestillaccessibletorunninguserthreads.
答案:
B、E
QuestionNo:
2
2.Givethefollowingmethod:
1)publicvoidmethod(){
2}Stringa,b;
3}a=newString(“helloworld”);
4}b=newString(“gameover”);
5}System.out.println(a+b+”ok”);
6}a=null;
7}a=b;
8}System.out.println(a);
9}}
Intheabsenceofcompileroptimization,whichistheearliestpointtheobjectareferedisdefinitelyelibiletobegarbagecollection.
A.beforeline3
B.beforeline5
C.beforeline6
D.beforeline7
E.Beforeline9
答案:
D
QuestionNo:
3
3.Intheclassjava.awt.AWTEvent,whichistheparentclassuponwhichjdk1.1awteventsarebasedthereisamethodcalledgetIDwhichphraseaccuratelydescribesthereturnvalueofthismethod?
A.Itisareferencetotheobjectdirectlyaffectedbythecauseoftheevent.
B.Itisanindicationofthenatureofthecauseoftheevent.
C.Itisanindicationofthepositionofthemousewhenitcausedtheevent.
D.Inthecaseofamouseclick,itisanindicationofthetextunderthemouseatthetimeoftheevent.
E.Ittellsthestateofcertainkeysonthekeybordatthetimeoftheevent.
F.Itisanindicationofthetimeatwhichtheeventoccurred.
答案:
B
QuestionNo:
4
4.Whichstatementaboutlisteneristrue?
A.Mostcomponentallowmultiplelistenerstobeadded.
B.Ifmultiplelistenerbeaddtoasinglecomponent,theeventonlyaffectedonelistener.
C.Componentdon?
tallowmultiplelistenerstobeadd.
D.ThelistenermechanismallowsyoutocallanaddXxxxListenermethodasmanytimesasisneeded,specifyingasmanydifferentlistenersasyourdesignrequire.
答案:
A、D
QuestionNo:
5
5.Givethefollowingcode:
publicclassExample{
publicstaticvoidmain(Stringargs[]){
intl=0;
do{
System.out.println(“Doingitforlis:
”+l);
}while(--l>0)
System.out.println(“Finish”);
}
}
Whichwellbeoutput:
A.Doingitforlis3
B.Doingitforlis1
C.Doingitforlis2
D.Doingitforlis0
E.Doingitforlis?
C1
F.Finish
答案:
D、F
QuestionNo:
6
6.Givethecodefragment:
1)switch(x){
2}case1:
System.out.println(“Test1”);break;
3}case2:
4}case3:
System.out.println(“Test2”);break;
5}default:
System.out.println(“end”);
6}}
whichvalueofxwouldcause“Test2”totheoutput:
A.1
B.2
C.3
D.default
答案:
B.C
QuestionNo:
7
7.Giveincompletedmethod:
1)
2){if(unsafe()){//dosomething…}
3}elseif(safe()){//dotheother…}
4}}
Themethodunsafe()wellthroeanIOException,whichcompletesthemethodofdeclarationwhenaddedatlineone?
A.publicIOExceptionmethodName()
B.publicvoidmethodName()
C.publicvoidmethodName()throwIOException
D.publicvoidmethodName()throwsIOException
E.publicvoidmethodName()throwsException
答案:
D、F
QuestionNo:
8
8.Givethecodefragment:
if(x>4){
System.out.println(“Test1”);}
elseif(x>9){
System.out.println(“Test2”);}
else{
System.out.println(“Test3”);}
Whichrangeofvaluexwouldproduceofoutput“Test2”?
A.x<4
B.x>4
C.x>9
D.None
答案:
D
QuestionNo:
9
9.Givethefollowingmethod:
publicvoidexample(){
try{
unsafe();
System.out.println(“Test1”);
}catch(SafeExceptione){System.out.println(“Test2”);
}finally{System.out.println(“Test3”);}
System.out.println(“Test4”);
Whichwilldisplayifmethodunsafe()runnormally?
A.Test1
B.Test2
C.Test3
D.Test4
答案:
A、C、D
QuestionNo:
10
10.Whichmethodyoudefineasthestartingpointofnewthreadinaclassfromwhichnewthethreadcanbeexcution?
A.publicvoidstart()
B.publicvoidrun()
C.publicvoidint()
D.publicstaticvoidmain(Stringargs[])
E.publicvoidrunnable()
答案:
B
QuestionNo:
11
11.Giventhefollowingclassdefinition:
classA{
protectedinti;
A(inti){
this.i=i;
}
}
whichofthefollowingwouldbeavalidinnerclassforthisclass?
Selectallvalidanswers:
A.classB{
}
B.classBextendsA{
}
C.classBextendsA{
B(){System.out.println(“i=”+i);}
}
D.classB{
classA{}
}
E.classA{}
答案:
A
QuestionNo:
12
12.Whichmodifiershouldbeappliedtoamethodforthelockofobjectthistobeobtainedpriortoexcutionanyofthemethodbody?
A.synchronized
B.abstract
C.final
D.static
E.public
答案:
A
QuestionNo:
13
13.ThefollowingcodeisentirecontentsofafilecalledExample.java,causespreciselyoneerrorduringcompilation:
1)classSubClassextendsBaseClass{
2}}
3)classBaseClass(){
4}Stringstr;
5}publicBaseClass(){
6}System.out.println(“ok”);}
7}publicBaseClass(Strings){
8}str=s;}}
9)publicclassExample{
10}publicvoidmethod(){
11}SubClasss=newSubClass(“hello”);
12}BaseClassb=newBaseClass(“world”);
13}}
14}}
Whichlinewouldbecausetheerror?
A.9B.10C.11D.12
答案:
C
QuestionNo:
14
14.Whichstatementiscorrectlydeclareavariableawhichissuitableforreferingtoanarrayof50stringemptyobject?
A.String[]a
B.Stringa[]
C.chara[][]
D.Stringa[50]
F.Objecta[50]
答案:
A、B
QuestionNo:
15
15.Givethefollowingjavasourcefragement:
//pointx
publicclassInteresting{
//dosomething
}
WhichstatementiscorrectlyJavasyntaxatpointx?
A.importjava.awt.*;
B.packagemypackage
C.staticintPI=3.14
D.publicclassMyClass{//dootherthing…}E.classMyClass{//dosomething…}
答案:
A、E
QuestionNo:
16
16.Givethisclassoutline:
classExample{
privateintx;
//restofclassbody…
}
AssumingthatxinvokedbythecodejavaExample,whichstatementcanmadexbedirectlyaccessibleinmain()methodofExample.java?
A.Changeprivateintxtopublicintx
B.changeprivateintxtostaticintx
C.Changeprivateintxtoprotectedintx
D.changeprivateintxtofinalintx
答案:
B
QuestionNo:
17
17.thepieceofpreliminaryanalsisworkdescribesaclassthatwillbeusedfrequentlyinmanyunrelatedpartsofaproject
“Thepolygonobjectisadrawable,Apolygonhasvertexinformationstoredinavector,acolor,lengthandwidth.”
WhichDatatypewouldbeused?
A.Vector
B.int
C.String
D.Color
E.Date
答案:
A、B、D
QuestionNo:
18
18.Aclassdesignrequiresthatamembervariableshouldbeaccessibleonlybysamepackage,whichmodiferwordshouldbeused?
A.protected
B.public
C.nomodifer
D.private
答案:
C
QuestionNo:
19
19.Whichdeclaresfornativemethodinajavaclasscorrected?
A.publicnativevoidmethod(){}
B.publicnativevoidmethod();
C.publicnativemethod();
D.publicvoidmethod(){native;}
E.publicvoidnativemethod();
答案:
B
QuestionNo:
20
20.Whichmodifershouldbeappliedtoadeclarationofaclassmembervariableforthevalueofvariabletoremainconstantafterthecreationoftheobject?
答案:
final
QuestionNo:
21
21.Whichisthemain()methodreturnofaapplication?
A.String
B.byte
C.char
D.void
答案:
D
QuestionNo:
22
22.Whichiscorrectedargumentofmain()methodofapplication?
A.Stringargs
B.Stringar[]
C.Charargs[][]
D.StringBufferarg[]
答案:
B
QuestionNo:
23
23.“TheEmployeeobjectisaperson,AnEmployeehasappointmentstoreinavector,ahiredateandanumberofdependent”
shortanswer:
useshorteststatementdeclareaclassofEmployee.
答案:
publicclassEmployeeextendsPerson
QuestionNo:
24
24.Givethefollowingclassdefinationinseparatesourcefiles:
publicclassExample{
publicExample(){//dosomething}
protectedExample(inti){//dosomething}
protectedvoidmethod(){//dosomething}
}
publicclassHelloextendsExample{//membermethodandmembervariable}
WhichmethodsarecorrectedaddedtotheclassHello?
A.publicvoidExample(){}
B.publicvoidmethod(){}
C.protectedvoidmethod(){}
D.privatevoidmethod(){}
答案:
A、B、C
QuestionNo:
25
25.Floats=newFloat(0.9F);
Floatt=newFloat(0.9F);
Doubleu=newDouble(0.9);
Whichexpression?
sresultistrue?
A.s==t
B.s.equals(t)
C.s==u
D.t.equals(u)
答案:
A、B
QuestionNo:
26
26.Givefollowingclass:
classAClass{
privatelongval;
publicAClass(longv){val=v;}
publicstaticvoidmain(Stringargs[]){
AClassx=newAClass(10L);
AClassy=newAClass(10L);
AClassz=y;
longa=10L;
intb=10;
}
}
Whichexpressionresultistrue?
A.a==b;
B.a==x;
C.y==z;
D.x==y;
E.a==10.0;
答案:
A、C、E
QuestionNo:
27
27.Asocketobjecthasbeencreatedandconnectedtoastandardinternetserviceonaremotenetworkserver.WhichconstructiongivethemostsuitablemeansforreadingASCIIdataonlineatatimefromthesocket?
A.InputStreamin=s.getInputStream();
B.DataInputStreamin=newDataInputstream(s.getInputStream());
C.ByteArrayInputStreamin=newByteArrayInputStream(s.getInputStream());
D.BufferedReaderin=newBufferedReader(newInputStreamReader(s.getInputStream()));
E.BufferedReaderin=newBufferedReader(newInputStreamReader(s.getInputStream()),”8859-1”);
答案:
E
QuestionNo:
28
28.Strings=”ExampleString”;
Whichoperationislegal?
A.s>>>=3;
B.inti=s.length();
C.s[3]=”x”;
D.Stringshort_s=s.trim();
E.Str
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- SCJP 模拟 试题