SCJP Mock Exam 2.docx
《SCJP Mock Exam 2.docx》由会员分享,可在线阅读,更多相关《SCJP Mock Exam 2.docx(43页珍藏版)》请在冰豆网上搜索。
![SCJP Mock Exam 2.docx](https://file1.bdocx.com/fileroot1/2022-12/30/af33e4b9-9385-42c2-a1a7-b3a7d80b4e07/af33e4b9-9385-42c2-a1a7-b3a7d80b4e071.gif)
SCJPMockExam2
Question1)
Whichofthefollowingarelegalstatements?
1)floatf=1/3;
2)inti=1/3;
3)floatf=1.01;
4)doubled=999d;
AnswertoQuestion1)
--------------------------------------------------------------------------------
Question2)
WhichofthefollowingareJavakeywords?
1)NULL
2)new
3)instanceOf
4)wend
AnswertoQuestion2)
--------------------------------------------------------------------------------
Question3)
Whichofthefollowingarevalidstatements?
1)System.out.println(1+1);
2)inti=2+'2';
3)c
4)byteb=255;
AnswertoQuestion3)
--------------------------------------------------------------------------------
Question4)
Whichofthefollowingstatementsaretrue?
1)ThegarbagecollectionalgorithminJavaisvendorimplemented
2)Thesizeofprimitivesisplatformdependent
3)Thedefaulttypeforanumericalliteralwithdecimalcomponentisafloat.
4)YoucanmodifythevalueinanInstanceoftheIntegerclasswiththesetValuemethod
AnswertoQuestion4)
--------------------------------------------------------------------------------
Question5)
Whichofthefollowingaretruestatements?
1)I/OinJavacanonlybeperformedusingtheListenerclasses
2)TheRandomAccessFileclassallowsyoutomovedirectlytoanypointafile.
3)ThecreationofanamedinstanceoftheFileclasscreatesamatchingfileintheunderlyingoperatingsystemonlywhentheclosemethodiscalled.
4)ThecharacteristicsofaninstanceoftheFileclasssuchasthedirectoryseparator,dependonthecurrentunderlyingoperatingsystem
AnswertoQuestion5)
--------------------------------------------------------------------------------
Question6).
Whichofthefollowingstatementsaretrue?
1)Theinstanceofoperatorcanbeusedtodetermineifareferenceisaninstanceofaclass,butnotaninterface.
2)Theinstanceofoperatorcanbeusedtodetermineifareferenceisaninstanceofaparticularprimitivewrapperclass
3)Theinstanceofoperatorwillonlydetermineifareferenceisaninstanceofaclassimmediatelyaboveinthehierarchybutnofurtheruptheinheritancechain
4)Theinstanceofoperatorcanbeusedtodetermineifonereferenceisofthesameclassasanotherreferencethus
AnswertoQuestion6)
--------------------------------------------------------------------------------
Question7)
Whichofthefollowingstatementsaretrue?
1)Aninterfacecanonlycontainmethodandnotvariables
2)Interfacescannothaveconstructors
3)Aclassmayextendonlyoneotherclassandimplementonlyoneinterface
4)InterfacesaretheJavaapproachtoaddressingitslackofmultipleinheritance,butrequireimplementingclassestocreatethefunctionalityoftheInterfaces.
AnswertoQuestion7)
--------------------------------------------------------------------------------
Question8)
Whichofthefollowingarevalidstatements
1)publicclassMyCalcextendsMath
2)Math.max(s);
3)Math.round(9.99,1);
4)Math.mod(4,10);
AnswertoQuestion8)
--------------------------------------------------------------------------------
Question9)
WhichofthefollowingaremethodsoftheRunnableinterface
1)run
2)start
3)yield
4)stop
AnswertoQuestion9)
--------------------------------------------------------------------------------
Question10)
Whichofthefollowingstatementsaretrue?
1)Abytecanrepresentbetween-128to127
2)Abytecanrepresentbetween-127to128
3)Abytecanrepresentbetween-256to256
4)Acharcanrepresentbetween-2x2pow162x2pow16-1
AnswertoQuestion10)
--------------------------------------------------------------------------------
Question11)
Whatwillhappenwhenyouattempttocompileandrunthefollowingcode
classBase{
publicvoidBase(){
System.out.println("Base");
}
}
publicclassInextendsBase{
publicstaticvoidmain(Stringargv[]){
Ini=newIn();
}
}
1)CompiletimeerrorBaseisakeyword
2)Compilationandnooutputatruntime
3)OutputofBase
4)RuntimeerrorBasehasnovalidconstructor
AnswertoQuestion11)
--------------------------------------------------------------------------------
Question12)
Youhaveapublicclasscalledmyclasswiththemainmethoddefinedasfollows
publicstaticvoidmain(Stringparm[]){
System.out.println(parm[0]);
}
Ifyouattempttocompiletheclassandruntheprogramasfollows
javamyclasshello
Whatwillhappen?
1)Compiletimeerror,mainisnotcorrectlydefined
2)Runtimeerror,mainisnotcorrectlydefined
3)Compilationandoutputofjava
4)Compilationandoutputofhello
AnswertoQuestion12)
--------------------------------------------------------------------------------
Question13)
Whichofthefollowingstatementsaretrue?
1)Ifaclasshasanyabstractmethodsitmustbedeclaredabstractitself.
2)Allmethodsinanabstractclassmustbedeclaredasabstract
3)Whenappliedtoaclass,thefinalmodifiermeansitcannotbesub-classed
4)transientandvolatileareJavamodifiers
AnswertoQuestion13)
--------------------------------------------------------------------------------
Question14)
Whichofthefollowingarevalidmethods?
1)publicstaticnativevoidamethod(){}
2)publicstaticvoidameticnativevoidamethod(){}
3)privateprotectedvoidamethod(){}
4)staticnativevoidamethod();
AnswertoQuestion14)
--------------------------------------------------------------------------------
Question15)
Whichofthefollowingstatementsaretrue?
1)Constructorscannothaveavisibilitymodifier
2)Constructorscanbemarkedpublicandprotected,butnotprivate
3)Constructorscanonlyhaveaprimitivereturntype
4)Constructorsarenotinherited
AnswertoQuestion15)
--------------------------------------------------------------------------------
Question16)
Whatwillhappenwhenyouattempttocompileandrunthefollowingclass?
classBase{
Base(inti){
System.out.println("Base");
}
}
classSevernextendsBase{
publicstaticvoidmain(Stringargv[]){
Severns=newSevern();
}
voidSevern(){
System.out.println("Severn");
}
}
1)Compilationandoutputofthestring"Severn"atruntime
2)Compiletimeerror
3)Compilationandnooutputatruntime
4)Compilationandoutputofthestring"Base"
AnswertoQuestion16)
--------------------------------------------------------------------------------
Question17)
Whichofthefollowingstatementsaretrue?
1)staticmethodsdonothaveaccesstotheimplicitvariablecalledthis
2)Astaticmethodmaybecalledwithoutcreatinganinstanceofitsclass
3)Astaticmethodmaynotbeoverridentobenon-static
4)Astaticmethodmaynotbeoverloaded
Answertoquestion17)
--------------------------------------------------------------------------------
Question18)
Whichofthefollowingwillcompilewithouterror?
1)
charc='1';
System.out.println(c>>1);
2)
Integeri=Integer("1");
System.out.println(i>>1);
3)
inti=1;
System.out.println(i<<<1);
4)
inti=1;
System.out.println(i<<1);
AnswertoQuestion18)
--------------------------------------------------------------------------------
Question19)
Whichofthefollowingaretrue?
1)Acomponentmayhaveonlyoneeventlistenerattachedatatime
2)Aneventlistenermayberemovedfromacomponent
3)TheActionListenerinterfacehasnocorrespondingAdapterclass
4)Theprocessingofaneventlistenerrequiresatry/catchblock
AnswertoQuestion19)
--------------------------------------------------------------------------------
Question20)
WhichofthefollowingareJavakeywords?
1)sizeof
2)main
3)transient
4)volatile
AnswertoQuestion20)
--------------------------------------------------------------------------------
Question21)
Whichofthefollowingstatementsaretrue?
1)Thedefaultconstructorhasareturntypeofvoid
2)Thedefaultconstructortakesaparameterofvoid
3)Thedefaultconstructortakesnoparameters
4)Thedefaultconstructorisnotcreatediftheclasshasanyconstructorsofitsown.
AnswertoQuestion21)
--------------------------------------------------------------------------------
Question22)
Whichofthefollowingstatementsaretrue?
1)Allofthevariablesinaninterfaceareimplicitlystatic
2)Allofthevariablesinaninterfaceareimplicitlyfinal
3)Allofthemethodsinaninterfaceareimplicitlyabstract
4)Amethodinaninterfacecanaccessclasslevelvariables
AnswertoQuestion22)
--------------------------------------------------------------------------------
Question23)
Whichofthefollowingstatementsaretrue?
1)TheStringclassisimplementedasachararray,elementsareaddressedusingthestringname[]convention
2)The+operatorisoverloadedforconcatenationfortheStringclass
3)StringsareaprimitivetypeinJavaandtheStringBufferisusedasthematchingwrappertype
4)Thesizeofastringcanberetrievedusingthelengthproperty
AnswertoQuestion23)
--------------------------------------------------------------------------------
Question24)
Whichofthefollowingstatementsaretrue?
1)Amethodinaninterfacemustnothaveabody
2)Aclassmayextendoneotherclassplusatmostoneinterface
3)Aclassmayextendsatmostoneotherclassplusimplementmanyinterfaces
4)Anclassaccessesaninterfaceviathekeyworduses
AnswertoQuestion24)
--------------------------------------------------------------------------------
Question25)
Whichofthefollowingstatementsaretrue?
1)Thefollowingstatementwillproducearesultof1.System.out.println(-1>>>2);
2)Performinganunsignedleftshift(<<<)on