SSD3 选择题题库完整.docx
《SSD3 选择题题库完整.docx》由会员分享,可在线阅读,更多相关《SSD3 选择题题库完整.docx(12页珍藏版)》请在冰豆网上搜索。
SSD3选择题题库完整
SSD3选择题题库
1.WhichmethodmustexistineveryJavaapplication?
(a)begin
(b)paint
(c)init
(d)main
Correctansweris(d)
窗体顶端
2.
WhichofthefollowingisavalidcharacterliteralinJava?
(a)';'
(b)'<='
(c)"'"
(d)"a"
Correctanswer:
A
窗体底端
2.AJavaidentifiermaybeginwithallbutwhichofthefollowing?
(a)$
(b)if
(c)_(theunderscore)
(d)0
Correctansweris(d)
3.InthecontextofJavaprogramming,garbagecollectionrefersto
(a)automaticbalancingofparenthesisperformedbysomeeditors
(b)removalofJavaprogramsthatcouldcausedamagetoasystem
(c)conversionofcommentsintoJavadoccomments
(d)automaticreturnofmemorytotheheapforobjectsnolongerrequiredbytheprogram
Correctansweris(d)
4.WhatwillbeoutputwhenthefollowingJavaprogramsegmentisexecuted?
intx=5;
inty=2;
System.out.println(x+y);
(a)5+2
(b)52
(c)7
(d)52
Correctansweris(c)
5.Whichofthefollowingpartsofanif-else-statementisoptional?
(a)theifpart
(b)theelsepart
(c)theparenthesisaroundthecondition
(d)thecondition
Correctansweris(b)
6.WhichofthefollowingistheJavaloopconstructtypicallyusedwhentherangeisclear?
(a)while-loop
(b)for-loop
(c)switch-loop
(d)do-while-loop
Correctansweris(b)
8.ConsiderthefollowingJavaprogramsegment.
importjava.io.*;
publicclassTest{
publicTest(){
System.out.println("default");
}
publicTest(inti){
System.out.println("non-default");
}
publicstaticvoidmain(String[]args){
Testt=newTest
(2);
}
}
Whichofthefollowingwillbeoutputduringexecutionoftheprogramsegment?
(a)Thelineoftext"non-default"followedbythelineoftext"default"
(b)Thelineoftext"default"followedbythelineoftext"non-default"
(c)Thelineoftext"default"
(d)Thelineoftext"non-default"
Correctansweris(d)
9.WhatisthenameoftheJDKprogramthatprocessesJavadoccomments?
(a)java
(b)javac
(c)javacom
(d)javadoc
Correctansweris(d)
10.AccordingtotheJavacodeconventions,fileslongerthan_____linesshouldbe_____.
(a)100,encouraged
(b)100,avoided
(c)2000,avoided
(d)2000,encouraged
Correctansweris(c)
2.Theprimitivefloating-pointtypesavailableinJavaare_____and_____.
(a)real,double
(b)float,double
(c)real,float
(d)single,real
Correctansweris(b)
3.HowmanybytesarerequiredtorepresentaUnicodecharacter?
(a)Four
(b)One
(c)Three
(d)Two
Correctansweris(d)
5.Howmanylinesofoutputwillbeproducedbythefollowingcodefragment?
for(inti=0;i<4;++i){
for(intj=1;j<3;++j){
stdOut.println(i+j);
(a)12
(b)6
(c)10
(d)8
Correctansweris(d)
6.Howmanylinesofoutputwillbeproducedbythefollowingcodefragment?
for(inti=0;i<3;++i){
for(intj=0;j
stdOut.println(i+j);
}}
(a)6
(b)4
(c)3
(d)5
Correctansweris(c)
7.WhichofthefollowingstatementsaboutclassvariablesinJavaisnottrue?
(a)Classvariablesrequirethemodifierstaticinthedeclarations.
(b)Allobjectshavetheirowncopyoftheclassvariabledefinedintheinstantiatedclass.
(c)Non-staticmethodsinaclasscanaccesstheclassvariabledefinedinthesameclass.
(d)Classvariablesdonotneedthereferencetotheobjectoftheinstantiatedclasstoaccessthem.
Correctansweris(b)
8.Thetermclassvariableisasynonymfor
(a)aninstancevariable
(b)aread-onlyvariable
(c)aprivatedatafield
(d)astaticdatafield
Correctansweris(d)
9.WhichofthefollowingpatternsofcharactersopensaJavadoccommentblock?
(a)/**
(b)//
(c)/*
(d)**/
Correctansweris(a)
2.Thetermwrapperclassesrefersto
(a)theJavaclassesthatcontainatleasttwodatafields
(b)theJavaclassesthatcontainthemselves
(c)acollectionofJavaclassesthat"wrap"Javaprimitivetypes
(d)acollectionofJavaclassesthatcontainotherJavaclasses
Correctansweris(c)
3.Giventhefollowingcode,whatvaluewillbeoutputbythelaststatement?
StringTokenizerst=newStringTokenizer("thisis,a,testoftokens",",");
Strings;
intcount=0;
while(st.hasMoreTokens()){
s=st.nextToken();
++count;
}
stdOut.println(count);
(a)3
(b)1
(c)6
(d)4
Correctansweris(a)
5.ConsiderthefollowingJavaprogramsegment.
intx=5;
inty=2;
System.out.println(x+"1"+y);
Whichofthefollowingstatementsistrueabouttheprogramsegment?
(a)Theoutputcausedbythecodewillbe512.
(b)Theoutputcausedbythecodewillbe8.
(c)Thecodewillcauseacompilationerror.
(d)Theoutputcausedbythecodewillbe512.
Correctansweris(a)
6.ConsiderthefollowingJavaprogramsegment.
importjava.io.*;
publicclassSomeClass{
publicvoidx(){
thrownewRuntimeException("Exceptionfromx");
}
publicvoidy(){
thrownewIOException("Exceptionfromy");
}
}
Whichofthefollowingistrueconcerningthedefinitionsforthemethodsxandy?
(a)Neitherxnoryhasalegaldefinition.
(b)Bothxandyhavelegaldefinitions.
(c)xhasalegaldefinition,butyhasanillegaldefinition.
(d)xhasanillegaldefinition,butyhasalegaldefinition.
Correctansweris(c)
7.InJava,exceptionsthatarenothandledarepassedupthe
(a)exceptionladder
(b)callstack
(c)catchblocks
(d)blockhierarchy
Correctansweris(b)
10.Afteratypicaldebuggerencountersabreakpoint,theprogrammerusingthedebuggermayperformwhichofthefollowingactions?
1.Examinethevaluesofvariablesinthehaltedprogram
2.Executethecurrentline
3.Resumeexecutionofthehaltedprogram
(a)IIIonly
(b)I,II,andIII
(c)Ionly
(d)IandIIonly
Correctansweris(b)
1.ThenameofaJavasourcefile
(a)mustusetheextension.class
(b)mustbethesameastheclassitdefines,respectingcase
(c)mustbethesameastheclassitdefines,ignoringcase
(d)hasnorestrictions
Correctansweris(b)
5.Adifferencebetweenthemethodsprintandprintlnoftheclassjava.io.PrintWriteristhat
(a)printlnappendsanewlinetotheendofitsoutput,butprintdoesnot
(b)printappendsanewlinetotheendofitsoutput,butprintlndoesnot
(c)printlninsertsanewlineatthebeginningofitsoutput,butprintdoesnot
(d)printinsertsanewlineatthebeginningofitsoutput,butprintlndoesnot
Correctansweris(a)
6.WhatistherightwaytohandleabnormalitiesininputonJava?
(a)Byhandlingtheseproblemsbyprovidingexceptionhandlers
(b)ByalwaysspecifyingthethrowsclauseineverymethodheaderwherefileI/Oisperformed
(c)ByusingtheclassFileFilterwhichgracefullyfiltersoutbadinputdata
(d)Bywritingwhileloopstoguardagainstbadinput
Correctansweris(a)
7.AllJavaexceptionclassesarederivedfromtheclass
(a)java.lang.RuntimeException
(b)java.lang.Throwable
(c)java.lang.Error
(d)java.io.IOException
Correctansweris(b)
9.WhichofthefollowingstatementsistrueoftheconventionsoutlinedbySunMicrosystemsinthedocumententitledCodeConventionsfortheJavaProgrammingLanguage?
1.TheydefineastandardinterfacedefinitionlanguagethatmustbeusedforallJavaclasses.
2.Theyproviderecommendationsintendedtomakesourcecodeeasiertoreadandunderstand.
3.TheydescribeonemechanismfornetworkcommunicationbetweenJavaandC++programs.
(a)IIIonly
(b)I,II,andIII
(c)IIonly
(d)IandIIIonly
Correctansweris(c)
10.Atoolthatallowsprogrammerstoexecutelinesofaprogramonelineatatimeinordertohelplocatethesourceofaprogram'serrorsisknownasa(n)
(a)debugger
(b)stacktrace
(c)exceptionhandler
(d)scope
Correctansweris(a)
2.Whichofthefollowingisnottrueconcerningobjectsandtheirrepresentation?
(a)objectsarerepresentedbytheiraddresses
(b)objectsarerepresentedbyvalue
(c)objectsarerepresentedbyreference
(d)objectsarerepresentedindirectly
Correctansweris(b)
5.Inprogramming,aloopisgenerallyusedtoachieve
(a)branching
(b)succession
(c)repetition
(d)selection
Correctansweris(c)
7.Ifaclasscontainsaconstructor,thatconstructorwillbeinvoked
(a)eachtimeanobjectofthatclassgoesoutofscope
(b)onceatthebeginningofanyprogramthatusesthatclass
(c)oncethefirsttimeanobjectofthatclassisinstantiated
(d)eachtimeanobjectofthatclassisinstantiated
Correctansweris(d)
8.WhichofthefollowingcategorizationscanbeappliedtoboththedatafieldsandthemethodsinaJavaclass?
(a)nativeandnon-native
(b)staticandnon-static
(c)defaultandnon-default
(d)abstractandnon-abstract
Correctansweris(b)
10.AccordingtotheJavacodeconventions,filesthatcontainJavasourcecodehavethesuffix_____,andcompiledbytecodefileshavethesuffix_____.
(a).javac,.class
(b).java,.class
(c).class,.javac
(d).class,.java
Correctansweris(b)
2.Variablesofprimitivetypesarealsoreferredtoas
(a)references
(b)classes
(c)objects
(d)scalars
Correctansweris(d)
3.Basedonthefollowingdeclaration,whatdoesb1representjustafterthedeclarationisexecuted?
Buttonb1;
(a)a"default"Buttonobject
(b)aButtonobjectwithnolabel
(c)ablankButtonobject
(d)nothing
Correctansweris(d)
8.Thereturntypeforamethodthatreturnsnothingtoitscalleris
(a)notspecifiedinthemethoddefinition
(b)false
(c)null
(d)void
Correctansweris(d)
2.Whatisthenameofthewrapperclassforthetypeint?
(a)Integer
(b)INT
(c)integer
(d)Int
Correctansweris(a)
3.Whichofthefollowingstatementsis(are)trueabouttheuseofanast