SCJP模拟试题Word下载.docx
- 文档编号:18989843
- 上传时间:2023-01-02
- 格式:DOCX
- 页数:20
- 大小:22.80KB
SCJP模拟试题Word下载.docx
《SCJP模拟试题Word下载.docx》由会员分享,可在线阅读,更多相关《SCJP模拟试题Word下载.docx(20页珍藏版)》请在冰豆网上搜索。
3
3.Intheclassjava.awt.AWTEvent,whichistheparentclassuponwhichjdk1.1awteventsarebasedthereisamethodcalledgetIDwhichphraseaccuratelydescribesthereturnvalueofthismethod?
A.Itisareferencetotheobjectdirectlyaffectedbythecauseoftheevent.
B.Itisanindicationofthenatureofthecauseoftheevent.
C.Itisanindicationofthepositionofthemousewhenitcausedtheevent.
D.Inthecaseofamouseclick,itisanindicationofthetextunderthemouseatthetimeoftheevent.
E.Ittellsthestateofcertainkeysonthekeybordatthetimeoftheevent.
F.Itisanindicationofthetimeatwhichtheeventoccurred.
B
4
4.Whichstatementaboutlisteneristrue?
A.Mostcomponentallowmultiplelistenerstobeadded.
B.Ifmultiplelistenerbeaddtoasinglecomponent,theeventonlyaffectedonelistener.
C.Componentdon?
tallowmultiplelistenerstobeadd.
D.ThelistenermechanismallowsyoutocallanaddXxxxListenermethodasmanytimesasisneeded,specifyingasmanydifferentlistenersasyourdesignrequire.
A、D
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
6
6.Givethecodefragment:
1)switch(x){
2}case1:
System.out.println(“Test1”);
break;
3}case2:
4}case3:
System.out.println(“Test2”);
5}default:
System.out.println(“end”);
6}}
whichvalueofxwouldcause“Test2”totheoutput:
A.1
B.2
C.3
D.default
B.C
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
8
8.Givethecodefragment:
if(x>
4){
elseif(x>
9){
else{
System.out.println(“Test3”);
Whichrangeofvaluexwouldproduceofoutput“Test2”?
A.x<
4
B.x>
C.x>
9
D.None
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
10
10.Whichmethodyoudefineasthestartingpointofnewthreadinaclassfromwhichnewthethreadcanbeexcution?
A.publicvoidstart()
B.publicvoidrun()
C.publicvoidint()
D.publicstaticvoidmain(Stringargs[])
E.publicvoidrunnable()
B
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
12
12.Whichmodifiershouldbeappliedtoamethodforthelockofobjectthistobeobtainedpriortoexcutionanyofthemethodbody?
A.synchronized
B.abstract
C.final
D.static
E.public
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
14
14.Whichstatementiscorrectlydeclareavariableawhichissuitableforreferingtoanarrayof50stringemptyobject?
A.String[]a
B.Stringa[]
C.chara[][]
D.Stringa[50]
F.Objecta[50]
A、B
15
15.Givethefollowingjavasourcefragement:
//pointx
publicclassInteresting{
//dosomething
WhichstatementiscorrectlyJavasyntaxatpointx?
A.importjava.awt.*;
B.packagemypackage
C.staticintPI=3.14
D.publicclassMyClass{//dootherthing…}E.classMyClass{//dosomething…}
A、E
16
16.Givethisclassoutline:
classExample{
privateintx;
//restofclassbody…
AssumingthatxinvokedbythecodejavaExample,whichstatementcanmadexbedirectlyaccessibleinmain()methodofExample.java?
A.Changeprivateintxtopublicintx
B.changeprivateintxtostaticintx
C.Changeprivateintxtoprotectedintx
D.changeprivateintxtofinalintx
17
17.thepieceofpreliminaryanalsisworkdescribesaclassthatwillbeusedfrequentlyinmanyunrelatedpartsofaproject
“Thepolygonobjectisadrawable,Apolygonhasvertexinformationstoredinavector,acolor,lengthandwidth.”
WhichDatatypewouldbeused?
A.Vector
B.int
C.String
D.Color
E.Date
A、B、D
18
18.Aclassdesignrequiresthatamembervariableshouldbeaccessibleonlybysamepackage,whichmodiferwordshouldbeused?
A.protected
B.public
C.nomodifer
D.private
19
19.Whichdeclaresfornativemethodinajavaclasscorrected?
A.publicnativevoidmethod(){}
B.publicnativevoidmethod();
C.publicnativemethod();
D.publicvoidmethod(){native;
E.publicvoidnativemethod();
20
20.Whichmodifershouldbeappliedtoadeclarationofaclassmembervariableforthevalueofvariabletoremainconstantafterthecreationoftheobject?
final
21
21.Whichisthemain()methodreturnofaapplication?
A.String
B.byte
C.char
D.void
22
22.Whichiscorrectedargumentofmain()methodofapplication?
A.Stringargs
B.Stringar[]
C.Charargs[][]
D.StringBufferarg[]
23
23.“TheEmployeeobjectisaperson,AnEmployeehasappointmentstoreinavector,ahiredateandanumberofdependent”
shortanswer:
useshorteststatementdeclareaclassofEmployee.
publicclassEmployeeextendsPerson
24
24.Givethefollowingclassdefinationinseparatesourcefiles:
publicExample(){//dosomething}
protectedExample(inti){//dosomething}
protectedvoidmethod(){//dosomething}
publicclassHelloextendsExample{//membermethodandmembervariable}
WhichmethodsarecorrectedaddedtotheclassHello?
A.publicvoidExample(){}
B.publicvoidmethod(){}
C.protectedvoidmethod(){}
D.privatevoidmethod(){}
A、B、C
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)
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
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
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 模拟 试题
![提示](https://static.bdocx.com/images/bang_tan.gif)