scjp1.docx
- 文档编号:3812488
- 上传时间:2022-11-25
- 格式:DOCX
- 页数:20
- 大小:22.11KB
scjp1.docx
《scjp1.docx》由会员分享,可在线阅读,更多相关《scjp1.docx(20页珍藏版)》请在冰豆网上搜索。
scjp1
scjp模拟试题
(一)
QuestionNo:
1
1.publicclasstest(
2.publicstaticvoidmain(Stringargs[]){
3.inti=0xFFFFFFF1;
4.intj=~i;
5.
6.}
7.)
Whatisthedecimalvalueofjatline5?
A.0
B.1
C.14
D.–15
E.Anerroratline3causescompilationtofail.
F.Anerroratline4causescompilationtofail.
答案:
C
QuestionNo:
2
Given:
Integeri=newInteger(42);
Long1=newLong(42);
Doubled=newDouble(42.0);
WhichtwoexpressionsevaluatetoTrue?
(ChooseTwo)
A.(i==1)
B.(i==d)
C.(d==1)
D.(i.equals(d))
E.(d.equals(i))
F.(i.equals(42))
答案:
D,E
QuestionNo:
3
Exhibit:
1.publicclasstest(
2.privatestaticintj=0;
3.
4.privatestaticbooleanmethodB(intk)(
5.j+=k;
6.returntrue;
6.)
7.
8.publicstaticvoidmethodA(inti){
9.booleanb:
10.b=i<10|methodB(4);
11.b=i<10||methodB(8);
12.}
13.
14.publicstaticvoidmain(Stringargs[])(
15.methodA(0);
16.system.out.printIn(j);
17.)
18.)
Whatistheresult?
A.Theprogramprints“0”
B.Theprogramprints“4”
C.Theprogramprints“8”
D.Theprogramprints“12”
E.Thecodedoesnotcomplete.
答案:
B
QuestionNo:
4
Given
1.Publicclasstest(
2.Publicstaticvoidmain(Stringargs[])(
3.System.out.printIn(6^3);
4.)
5.)
Whatistheoutput?
答案:
5
QuestionNo:
5
Given:
1.publicclassFoo{
2.publicstaticvoidmain(String[]args){
3.StringBuffera=newStringBuffer(“A”);
4.StringBufferb=newStringBuffer(“B”);
5.operate(a,b);
6.system.out.printIn{a+“,”+b};
7.}
8.staticvoidoperate(StringBufferx,StringBuffery){
9.x.append{y};
10.y=x;
11.}
12.}
Whatistheresult?
A.Thecodecompilesandprints“A,B”.
B.Thecodecompilesandprints“A,A”.
C.Thecodecompilesandprints“B,B”.
D.Thecodecompilesandprints“AB,B”.
E.Thecodecompilesandprints“AB,AB”.
F.Thecodedoesnotcompilebecause“+”cannotbeoverloadedforStringBuffer.
答案:
D
QuestionNo:
6
Exhibit:
1.Publicclasstest(
2.PublicstaticvoidstringReplace(Stringtext)(
3.Text=text.replace(‘j’,‘i’);
4.)
5.
6.publicstaticvoidbufferReplace(StringBuffertext)(
7.text=text.append(“C”)
8.)
9.
10.publicstaticvoidmain(Stringargs[])(
11.StringtextString=newString(“java”);
12.StringBuffertextBufferString=newStringBuffer(“java”);
13.
14.stringReplace(textString);
15.BufferReplace(textBuffer);
16.
17.System.out.printIn(textString+textBuffer);
18.)
19.)
Whatistheoutput?
答案:
JAVAJAVA
QuestionNo:
7
Exhibit:
1.publicclasstest{
2.publicstaticvoidadd3(Integeri)}
3.intval=i.intValue();
4.val+=3;
5.i=newInteger(val);
6.)
7.
8.publicstaticvoidmain(Stringargs[]){
9.Integeri=newInteger(0);
10.add3(i);
11.system.out.printIn(i.intValue());
12.}
13.)
Whatistheresult?
A.Compilationwillfail.
B.Theprogramprints“0”.
C.Theprogramprints“3”.
D.Compilationwillsucceedbutanexceptionwillbethrownatline3.
答案:
B
QuestionNo:
8
Given:
1.publicclassConstOver{
2.publicConstOver(intx,inty,intz){
3.}
4.}
WhichtwooverloadtheConstOverconstructor?
(ChooseTwo)
A.ConstOver(){}
B.ProtectedintConstOver(){}
C.PrivateConstOver(intz,inty,bytex){}
D.PublicObjectConstOver(intx,inty,intz){}
E.PublicvoidConstOver(bytex,bytey,bytez){}
答案:
A,C
QuestionNo:
9
Given:
1.publicclassMethodOver{
2.publicvoidsetVar(inta,intb,floatc){
3.}
4.}
WhichtwooverloadthesetVarmethod?
(ChooseTwo)
A.PrivatevoidsetVar(inta,floatc,intb){}
B.ProtectedvoidsetVar(inta,intb,floatc){}
C.PublicintsetVar(inta,floatc,intb)(returna;)
D.PublicintsetVar(inta,intb,floatc)(returna;)
E.ProtectedfloatsetVar(inta,intb,floatc)(returnc;)
答案:
A,C
QuestionNo:
10
Given:
1.classBaseClass{
2.Privatefloatx=1.0f;
3.protectedfloatgetVar()(returnx;)
4.}
5.classSubclassextendsBaseClass(
6.privatefloatx=2.0f;
7.//insertcodehere
8.)
Whichtwoarevalidexamplesofmethodoverriding?
(ChooseTwo)
A.FloatgetVar(){returnx;}
B.PublicfloatgetVar(){returnx;}
C.FloatdoublegetVar(){returnx;}
D.PublicfloatgetVar(){returnx;}
E.PublicfloatgetVar(floatf){returnf;}
答案:
B,D
QuestionNo:
11
Whichtwodemonstratean“isa”relationship?
(ChooseTwo)
A.publicinterfacePerson{}
publicclassEmployeeextendsPerson{}
B.publicinterfaceShape{}
publicclassEmployeeextendsShape{}
C.publicinterfaceColor{}
publicclassEmployeeextendsColor{}
D.publicclassSpecies{}
publicclassAnimal(privateSpeciesspecies;)
E.interfaceComponent{}
ClassContainerimplementsComponent(
PrivateComponent[]children;
)
答案:
D,E
QuestionNo:
12
Whichstatementistrue?
A.Ananonymousinnerclassmaybedeclaredasfinal.
B.Ananonymousinnerclasscanbedeclaredasprivate.
C.Ananonymousinnerclasscanimplementmultipleinterfaces.
D.Ananonymousinnerclasscanaccessfinalvariablesinanyenclosingscope.
E.Constructionofaninstanceofastaticinnerclassrequiresaninstanceoftheenclosingouterclass.
答案:
D
QuestionNo13
Given:
1.packagefoo;
2.
3.publicclassOuter(
4.publicstaticclassInner(
5.)
6.)
Whichstatementistrue?
A.AninstanceoftheInnerclasscanbeconstructedwith“newOuter.Inner()”
B.Aninstanceoftheinnerclasscannotbeconstructedoutsideofpackagefoo.
C.Aninstanceoftheinnerclasscanonlybeconstructedfromwithintheouterclass.
D.Fromwithinthepackagebar,aninstanceoftheinnerclasscanbeconstructedwith“newinner()”
答案:
A
QuestionNo14
Exhibit:
1.publicclassenclosingone(
2.publicclassinsideone{}
3.)
4.publicclassinertest(
5.publicstaticvoidmain(string[]args)(
6.enclosingoneeo=newenclosingone();
7.//insertcodehere
8.)
9.)
Whichstatementatline7constructsaninstanceoftheinnerclass?
A.InsideOnewei=eo.newInsideOn();
B.Eo.InsideOneei=eo.newInsideOne();
C.InsideOneei=EnclosingOne.newInsideOne();
D.EnclosingOne.InsideOneei=eo.newInsideOne();
答案:
D
QuestionNo15
Exhibit:
1.interfacefoo{
2.intk=0;
3.}
4.
5.publicclasstestimplementsFoo(
6.publicstaticvoidmain(Stringargs[])(
7.inti;
8.Testtest=newtest();
9.i=test.k;
10.i=Test.k;
11.i=Foo.k;
12.)
13.)
14.
Whatistheresult?
A.Compilationsucceeds.
B.Anerroratline2causescompilationtofail.
C.Anerroratline9causescompilationtofail.
D.Anerroratline10causescompilationtofail.
E.Anerroratline11causescompilationtofail.
答案:
A
QuestionNo16
Given:
1.//pointX
2.publicclassfoo(
3.publicstaticvoidmain(String[]args)throwsException{
4.printWriterout=newPrintWriter(new
5.java.io.outputStreamWriter(System.out),true;
6.out.printIn(“Hello”);
7.)
8.}
WhichstatementatPointXonline1allowsthiscodetocompileandrun?
A.Importjava.io.PrintWriter;
B.Includejava.io.PrintWriter;
C.Importjava.io.OutputStreamWriter;
D.Includejava.io.OutputStreamWriter;
E.Nostatementisneeded.
答案:
A
QuestionNo17
WhichtwostatementsarereservedwordsinJava?
(ChooseTwo)
A.Run
B.Import
C.Default
D.Implement
答案:
B,C
QuestionNo18
Whichthreearevaliddeclarationsofafloat?
(ChooseThree)
A.Floatfoo=-1;
B.Floatfoo=1.0;
C.Floatfoo=42e1;
D.Floatfoo=2.02f;
E.Floatfoo=3.03d;
F.Floatfoo=0x0123;
答案:
A,D,F
QuestionNo19
LeadingthewayinITtestingandcertificationtools,
QuestionNo19
Given:
8.intindex=1;
9.boolean[]test=newBoolean[3];
10.booleanfoo=test[index];
Whatistheresult?
A.Foohasthevalueof0.
B.Foohasthevalueofnull.
C.Foohasthevalueoftrue.
D.Foohasthevalueoffalse.
E.Anexceptionisthrown.
F.Thecodewillnotcompile.
答案:
D
QuestionNo20
Given:
1.publicclasstest(
2.publicstaticvoidmain(string[]args){
3.stringfoo=args[1];
4.stringfoo=args[2];
5.stringfoo=args[3];
6.}
7.)
Andcommandlineinvocation:
JavaTestredgreenblue
Whatistheresult?
A.Bazhasthevalueof“”
B.Bazhasthevalueofnull
C.Bazhasthevalueof“red”
D.Bazhasthevalueof“blue”
E.Baxhasthevalueof“green”
F.Thecodedoesnotcompile.
G.Theprogramthrowsanexception.
答案:
G
QuestionNo21
Given:
8.intindex=1;
9.int[]foo=newint[3];
10.intbar=foo[index];
11.intbaz=bar+index;
Whatistheresult?
A.Bazhasthevalueof0
B.Bazhasthevalueof1
C.Bazhasthevalueof2
D.Anexceptionisthrown.
E.Thecodewillnotcompile.
答案:
B
QuestionNo22
Given:
1.publicclassfoo{
2.publicstaticvoidmain(String[]args){
3.Strings;
4.system.out.printIn(“s=”+s);
5.}
6.}
Whatistheresult?
A.Thecodecompilesand“s=”isprinted.
B.Thecodecompilesand“s=null”isprinted.
C.Thecodedoesnotcompilebecausestringsisnotinitialized.
D.Thecodedoesnotcompilebecausestringscannotbereferenced.
E.Thecodecompiles,butaNullPointerExceptionisthrownwhentoStringiscalled.
答案:
C
QuestionNo23
Whichwilldeclareamethodthatforcesasubclasstoimplementit?
A.Publicdoublemethoda();
B.Staticvoidmethoda(doubled1){}
C.Publicnativedoublemethoda();
D.Abstractpublicvoidmethoda();
E.Protectedvoidmethoda(doubled1){}
答案:
D
QuestionNo24
Youwantsubclassesinanypackagetohaveaccesstomembersofasuperclass.Whichisthemost
restrictiveaccessmodifierthatwillaccomplishthisobjective?
A.Public
B.Private
C.Protected
D.Transient
E.Noaccessmodifieri
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- scjp1
![提示](https://static.bdocx.com/images/bang_tan.gif)