




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
轉(zhuǎn)載對(duì)題目和答案謹(jǐn)做參考
Q1
Amethodis...
1)animplementationofanabstraction.
2)anattributedefiningthepropertyofaparticularabstraction.
3)acategoryofobjects.
4)anoperationdefiningthebehaviorforaparticularabstraction.
5)ablueprintformakingoperations.
Q2
Anobjectis...
1)whatclassesareinstantiatedfrom.
2)aninstanceofaclass.
3)ablueprintforcreatingconcreterealizationofabstractions.
4)areferencetoanattribute.
5)avariable.
Q3
Whichlinecontainsaconstructorinthisclassdefinition?
publicclassCounter{//(1)
intcurrent,step;
publicCounter(intstartValue,intstepValue){//(2)
set(startValue);
setStepValue(stepValue);
}
publicintget(){returncurrent;}//(3)
publicvoidset(intvalue){current=value;}//(4)
publicvoidsetStepValue(intstepValue){step=stepValue;}//(5)
}
1)Codemarkedwith(1)isaconstructor
2)Codemarkedwith(2)isaconstructor
3)Codemarkedwith(3)isaconstructor
4)Codemarkedwith(4)isaconstructor
5)Codemarkedwith(5)isaConstructor
Q4
GiventhatThingisaclass,howmanyobjectsandreferencevariablesarecreatedbythefollowingcode?
Thingitem,stuff;
item=newThing();
Thingentity=newThing();
1)Oneobjectiscreated
2)Twoobjectsarecreated
3)Threeobjectsarecreated
4)Onereferencevariableiscreated
5)Tworeferencevariablesarecreated
6)Threereferencevariablesarecreated.
Q5
Aninstancemember…
1)isalsocalledastaticmember
2)isalwaysavariable
3)isneveramethod
4)belongstoasingleinstance,nottotheclassasawhole
5)alwaysrepresentsanoperation
Q6
HowdoobjectspassmessagesinJava?
1)Theypassmessagesbymodifyingeachother'smembervariables
2)Theypassmessagesbymodifyingthestaticmembervariablesofeachother'sclasses
3)Theypassmessagesbycallingeachother'sinstancemembermethods
4)Theypassmessagesbycallingstaticmembermethodsofeachother'sclasses.
Q7
Giventhefollowingcode,whichstatementsaretrue?
classA{
intvalue1;
}
classBextendsA{
intvalue2;
}
1)ClassAextendsclassB.
2)ClassBisthesuperclassofclassA.
3)ClassAinheritsfromclassB.
4)ClassBisasubclassofclassA.
5)ObjectsofclassAhaveamembervariablenamedvalue2.
Q8
IfthissourcecodeiscontainedinafilecalledSmallProg.java,whatcommandshouldbeusedtocompileitusingtheJDK?
publicclassSmallProg{
publicstaticvoidmain(Stringargs[]){System.out.println("Goodluck!");}
}
1)javaSmallProg
2)avacSmallProg
3)javaSmallProg.java
4)javacSmallProg.java
5)javaSmallProgmain
Q9
Giventhefollowingclass,whichstatementscanbeinsertedatposition1withoutcausingthecodetofailcompilation?
publicclassQ6db8{
inta;
intb=0;
staticintc;
publicvoidm(){
intd;
inte=0;
//Position1
}
}
1)a++;
2)b++;
3)c++;
4)d++;
5)e++;
Q10
Whichstatementsaretrueconcerningtheeffectofthe>>and>>>operators?
1)Fornon-negativevaluesoftheleftoperand,the>>and>>>operatorswillhavethesameeffect.
2)Theresultof(-1>>1)is0.
3)Theresultof(-1>>>1)is-1.
4)Thevaluereturnedby>>>willneverbenegativeaslongasthevalueoftherightoperandisequaltoorgreaterthan1.
5)Whenusingthe>>operator,theleftmostbitofthebitrepresentationoftheresultingvaluewillalwaysbethesamebitvalueastheleftmostbitofthebitrepresentationoftheleftoperand.
Q11
Whatiswrongwiththefollowingcode?
classMyExceptionextendsException{}
publicclassQb4ab{
publicvoidfoo(){
try{
bar();
}finally{
baz();
}catch(MyExceptione){}
}
publicvoidbar()throwsMyException{
thrownewMyException();
}
publicvoidbaz()throwsRuntimeException{
thrownewRuntimeException();
}
}
1)Sincethemethodfoo()doesnotcatchtheexceptiongeneratedbythemethodbaz(),itmustdeclaretheRuntimeExceptioninitsthrowsclause.
2)Atryblockcannotbefollowedbybothacatchandafinallyblock.
3)Anemptycatchblockisnotallowed.
4)Acatchblockcannotfollowafinallyblock.
5)Afinallyblockmustalwaysfollowoneormorecatchblocks.
Q12
Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?
publicclassQd803{
publicstaticvoidmain(Stringargs[]){
Stringword="restructure";
System.out.println(word.substring(2,3));
}
}
1)est
2)es
3)str
4)st
5)s
Q13
GiventhatastaticmethoddoIt()inaclassWorkrepresentsworktobedone,whatblockofcodewillsucceedinstartinganewthreadthatwilldothework?
CODEBLOCKA:
Runnabler=newRunnable(){
publicvoidrun(){
Work.doIt();
}
};
Threadt=newThread(r);
t.start();
CODEBLOCKB:
Threadt=newThread(){
publicvoidstart(){
Work.doIt();
}
};
t.start();
CODEBLOCKC:
Runnabler=newRunnable(){
publicvoidrun(){
Work.doIt();
}
};
r.start();
CODEBLOCKD:
Threadt=newThread(newWork());
t.start();
CODEBLOCKE:
Runnablet=newRunnable(){
publicvoidrun(){
Work.doIt();
}
};
t.run();
1)CodeblockA.
2)CodeblockB.
3)CodeblockC.
4)CodeblockD.
5)CodeblockE.
Q14
WritealineofcodethatdeclaresavariablenamedlayoutoftypeLayoutManagerandinitializesitwithanewobject,whichwhenusedwithacontainercanlayoutcomponentsinarectangulargridofequal-sizedrectangles,3componentswideand2componentshigh.
Q15
publicclassQ275d{
staticinta;
intb;
publicQ275d(){
intc;
c=a;
a++;
b+=c;
}
publicstaticvoidmain(Stringargs[]){
newQ275d();
}
}
1)Thecodewillfailtocompile,sincetheconstructoristryingtoaccessstaticmembers.
2)Thecodewillfailtocompile,sincetheconstructoristryingtousestaticmembervariableabeforeithasbeeninitialized.
3)Thecodewillfailtocompile,sincetheconstructoristryingtousemembervariablebbeforeithasbeeninitialized.
4)Thecodewillfailtocompile,sincetheconstructoristryingtouselocalvariablecbeforeithasbeeninitialized.
5)Thecodewillcompileandrunwithoutanyproblems.
Q16
Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?
publicclassQ63e3{
publicstaticvoidmain(Stringargs[]){
System.out.println(9^2);
}
}
1)81
2)7
3)11
4)0
5)false
Q17
Whichstatementsaretrueconcerningthedefaultlayoutmanagerforcontainersinthejava.awtpackage?
1)ObjectsinstantiatedfromPaneldonothaveadefaultlayoutmanager.
2)ObjectsinstantiatedfromPanelhaveFlowLayoutasdefaultlayoutmanager.
3)ObjectsinstantiatedfromApplethaveBorderLayoutasdefaultlayoutmanager.
4)ObjectsinstantiatedfromDialoghaveBorderLayoutasdefaultlayoutmanager.
5)ObjectsinstantiatedfromWindowhavethesamedefaultlayoutmanagerasinstancesofApplet.
Q18
Whichdeclarationswillallowaclasstobestartedasastandaloneprogram?
1)publicvoidmain(Stringargs[])
2)publicvoidstaticmain(Stringargs[])
3)publicstaticmain(String[]argv)
4)finalpublicstaticvoidmain(String[]array)
5)publicstaticvoidmain(Stringargs[])
Q19
Underwhichcircumstanceswillathreadstop?
1)ThemethodwaitforId()inclassMediaTrackeriscalled.
2)Therun()methodthatthethreadisexecutingends.
3)Thecalltothestart()methodoftheThreadobjectreturns.
4)Thesuspend()methodiscalledontheThreadobject.
5)Thewait()methodiscalledontheThreadobject.
Q20
Whencreatingaclassthatassociatesasetofkeyswithasetofvalues,whichoftheseinterfacesismostapplicable?
1)Collection
2)Set
3)SortedSet
4)Map
Q21
WhatdoesthevaluereturnedbythemethodgetID()foundinclassjava.awt.AWTEventuniquelyidentify?
1)Theparticulareventinstance.
2)Thesourceoftheevent.
3)Thesetofeventsthatweretriggeredbythesameaction.
4)Thetypeofevent.
5)Thetypeofcomponentfromwhichtheeventoriginated.
Q22
Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?
classBase{
inti;
Base(){
add(1);
}
voidadd(intv){
i+=v;
}
voidprint(){
System.out.println(i);
}
}
classExtensionextendsBase{
Extension(){
add(2);
}
voidadd(intv){
i+=v*2;
}
}
publicclassQd073{
publicstaticvoidmain(Stringargs[]){
bogo(newExtension());
}
staticvoidbogo(Baseb){
b.add(8);
b.print();
}
}
1)9
2)18
3)20
4)21
5)22
Q23
Whichlinesofcodearevaliddeclarationsofanativemethodwhenoccurringwithinthedeclarationofthefollowingclass?
publicclassQf575{
//insertdeclarationofanativemethodhere
}
1)nativepublicvoidsetTemperature(intkelvin);
2)privatenativevoidsetTemperature(intkelvin);
3)protectedintnativegetTemperature();
4)publicabstractnativevoidsetTemperature(intkelvin);
5)nativeintsetTemperature(intkelvin){}
Q24
HowdoestheweightypropertyoftheGridBagConstraintsobjectsusedingridbaglayoutaffectthelayoutofthecomponents?
1)Itaffectswhichgridcellthecomponentsendupin.
2)Itaffectshowtheextraverticalspaceisdistributed.
3)Itaffectsthealignmentofeachcomponent.
4)Itaffectswhetherthecomponentscompletelyfilltheirallotteddisplayareavertically.
Q25
Whichstatementscanbeinsertedattheindicatedpositioninthefollowingcodetomaketheprogramwrite1onthestandardoutputwhenrun?
publicclassQ4a39{
inta=1;
intb=1;
intc=1;
classInner{
inta=2;
intget(){
intc=3;
//insertstatementhere
returnc;
}
}
Q4a39(){
Inneri=newInner();
System.out.println(i.get());
}
publicstaticvoidmain(Stringargs[]){
newQ4a39();
}
}
1)c=b;
2)c=this.a;
3)c=this.b;
4)c=Q4a39.this.a;
5)c=c;
Q26
Whichistheearliestlineinthefollowingcodeafterwhichtheobjectcreatedonthelinemarked(0)willbeacandidateforbeinggarbagecollected,assumingnocompileroptimizationsaredone?
publicclassQ76a9{
staticStringf(){
Stringa="hello";
Stringb="bye";//(0)
Stringc=b+"!";//(1)
Stringd=b;
b=a;//(2)
d=a;//(3)
returnc;//(4)
}
publicstaticvoidmain(Stringargs[]){
Stringmsg=f();
System.out.println(msg);//(5)
}
}
1)Thelinemarked(1).
2)Thelinemarked(2).
3)Thelinemarked(3).
4)Thelinemarked(4).
5)Thelinemarked(5).
Q27
WhichmethodsfromtheStringandStringBufferclassesmodifytheobjectonwhichtheyarecalled?
1)ThecharAt()methodoftheStringclass.
2)ThetoUpperCase()methodoftheStringclass.
3)Thereplace()methodoftheStringclass.
4)Thereverse()methodoftheStringBufferclass.
5)Thelength()methodoftheStringBufferclass.
Q28
Whichstatements,wheninsertedattheindicatedpositioninthefollowingcode,willcausearuntimeexceptionwhenattemptingtoruntheprogram?
classA{}
classBextendsA{}
classCextendsA{}
publicclassQ3ae4{
publicstaticvoidmain(Stringargs[]){
Ax=newA();
By=newB();
Cz=newC();
//insertstatementhere
}
}
1)x=y;
2)z=x;
3)y=(B)x;
4)z=(C)y;
5)y=(A)y;
Q29
WhichofthesearekeywordsinJava?
1)default
2)NULL
3)String
4)throws
5)long
Q30
Itisdesirablethatacertainmethodwithinacertainclasscanonlybeaccessedbyclassesthataredefinedwithinthesamepackageastheclassofthemethod.Howcansuchrestrictionsbeenforced?
1)Markthemethodwiththekeywordpublic.
2)Markthemethodwiththekeywordprotected.
3)Markthemethodwiththekeywordprivate.
4)Markthemethodwiththekeywordpackage.
5)Donotmarkthemethodwithanyaccessibilitymodifiers.
Q31
Whichcodefragmentswillsucceedininitializingatwo-dimensionalarraynamedtabwithasizethatwillcausetheexpressiontab[3][2]toaccessavalidelement?
CODEFRAGMENTA:
int[][]tab={
{0,0,0},
{0,0,0}
};
CODEFRAGMENTB:
inttab[][]=newint[4][];
for(inti=0;i
CODEFRAGMENTC:
inttab[][]={
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0
};
CODEFRAGMENTD:
inttab[3][2];
CODEFRAGMENTE:
int[]tab[]={{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
1)CodefragmentA.
2)CodefragmentB.
3)CodefragmentC.
4)CodefragmentD.
5)CodefragmentE.
Q32
Whatwillbetheresultofattemptingtorunthefollowingprogram?
publicclassQaa75{
publicstaticvoidmain(Stringargs[]){
String[][][]arr={
{{},null},
{{"1","2"},{"1",null,"3"}},
{},
{{"1",null}}
};
System.out.println(arr.length+arr[1][2].length);
}
}
1)TheprogramwillterminatewithanArrayIndexOutOfBoundsException.
2)TheprogramwillterminatewithaNullPointerException.
3)4willbewrittentostandardoutput.
4)6willbewrittentostandardoutput.
5)7willbewrittentostandardoutput.
Q33
Whichexpressionswillevaluatetotrueifprecededbythefollowingcode?
Stringa="hello";
Stringb=newString(a);
Stringc=a;
char[]d={'h','e','l','l','o'};
1)(a=="Hello")
2)(a==b)
3)(a==c)
4)a.equals(b)
5)a.equals(d)
Q34
Whichstatementsconcerningthefollowingcodearetrue?
classA{
publicA(){}
publicA(inti){this();}
}
classBextendsA{
publicbooleanB(Stringmsg){returnfalse;}
}
classCextendsB{
privateC(){super();}
publicC(Stringmsg){this();}
publicC(inti){}
}
1)Thecodewillfailtocompile.
2)TheconstructorinAthattakesanintasanargumentwillneverbecalledasaresultofconstructinganobjectofclassBorC.
3)ClassChasthreeconstructors.
4)ObjectsofclassBcannotbeconstructed.
5)AtmostoneoftheconstructorsofeachclassiscalledasaresultofconstructinganobjectofclassC.
Q35
Giventwocollectionobjectsreferencedbycol1andcol2,whichofthesestatementsaretrue?
1)Theoperationcol1.retainAll(col2)willnotmodifythecol1object.
2)Theoperationcol1.removeAll(col2)willnotmodifythecol2object.
3)Theoperationcol1.addAll(col2)willreturnanewcollectionobject,
containingelementsfrombothcol1andcol2.
4)Theoperationcol1.containsAll(Col2)willnotmodifythecol1object.
Q36
Whichstatementsconcerningtherelationshipsbetweenthefollowingclassesaretrue?
classFoo{
intnum;
Bazcomp=newBaz();
}
classBar{
booleanflag;
}
classBazextendsFoo{
Barthing=newBar();
doublelimit;
}
1)ABarisaBaz.
2)AFoohasaBar.
3)ABazisaFoo.
4)AFooisaBaz.
5)ABazhasaBar.
Q37
Whichstatementsconcerningthevalueofamembervariablearetrue,whennoexplicitassignmentshavebeenmade?
1)Thevalueofanintisundetermined.
2)Thevalueofallnumerictypesiszero.
3)Thecompilermayissueanerrorifthevariableisusedbeforeitisinitialized.
4)ThevalueofaStringvariableis""(emptystring).
5)Thevalueofallobjectvariablesisnull.
Q38
Whichstatementsdescribeguaranteedbehaviorofthegarbagecollectionandfinalizationmechanisms?
1)Objectsaredeletedwhentheycannolongerbeaccessedthroughanyreference.
2)Thefinalize()methodwilleventuallybecalledoneveryobject.
3)Thefinalize()methodwillneverbecalledmorethanonceonanobject.
4)Anobjectwillnotbegarbagecollectedaslongasitispossibleforanactivepartoftheprogramtoaccessitthroughareference.
5)Thegarbagecollectorwilluseamarkandsweepalgorithm.
Q39
Whichcodefragmentswillsucceedinprintingthelastargumentgivenonthecommandlinetothestandardoutput,andexitgracefullywithnooutputifnoargumentsaregiven?
CODEFRAGMENTA:
publicstaticvoidmain(Stringargs[]){
if(args.length!=0)
System.out.println(args[args.length-1]);
}
CODEFRAGMENTB:
publicstaticvoidmain(Stringargs[]){
try{System.out.println(args[args.length]);}
catch(ArrayIndexOutOfBoundsExceptione){}
}
CODEFRAGMENTC:
publicstaticvoidmain(Stringargs[]){
intix=args.length;
Stringlast=args[ix];
if(ix!=0)System.out.println(last);
}
CODEFRAGMENTD:
publicstaticvoidmain(Stringargs[]){
intix=args.length-1;
if(ix>0)System.out.println(args[ix]);
}
CODEFRAGMENTE:
publicstaticvoidmain(Stringargs[]){
try{System.out.println(args[args.length-1]);}
catch(NullPointerExceptione){}
}
1)CodefragmentA.
2)CodefragmentB.
3)CodefragmentC.
4)CodefragmentD.
5)CodefragmentE.
Q40
Whichofthesestatementsconcerningthecollectioninterfacesaretrue?
1)SetextendsCollection.
2)AllmethodsdefinedinSetarealsodefinedinCollection.
3)ListextendsCollection.
4)AllmethodsdefinedinListarealsodefinedinCollection.
5)MapextendsCollection.
Q41
Whatisthenameofthemethodthatthreadscanusetopausetheirexecutionuntilsignalledtocontinuebyanotherthread?
Fillinthenameofthemethod(donotincludeaparameterlist).
Q42
Giventhefollowingclassdefinitions,whichexpressionidentifieswhethertheobjectreferredtobyobjwascreatedbyinstantiatingclassBratherthanclassesA,CandD?
classA{}
classBextendsA{}
classCextendsB{}
classDextendsA{}
1)objinstanceofB
2)objinstanceofA&&!(objinstanceofC)
3)objinstanceofB&&!(objinstanceofC)
4)objinstanceofC||objinstanceofD
5)(objinstanceofA)&&!(objinstanceofC)&&!(objinstanceofD)
Q43
Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?
publicclassQ8499{
publicstaticvoidmain(Stringargs[]){
doubled=-2.9;
inti=(int)d;
i*=(int)Math.ceil(d);
i*=(int)Math.abs(d);
System.out.println(i);
}
}
1)12
2)18
3)8
4)12
5)27
Q44
Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?
publicclassQcb90{
inta;
intb;
publicvoidf(){
a=0;
b=0;
int[]c={0};
g(b,c);
System.out.println(a+""+b+""+c[0]+"");
}
publicvoidg(intb,int[]c){
a=1;
b=1;
c[0]=1;
}
publicstaticvoidmain(Stringargs[]){
Qcb90obj=newQcb90();
obj.f();
}
}
1)000
2)001
3)010
4)100
5)101
Q45
Whichstatementsconcerningtheeffectofthestatementgfx.drawRect(5,5,10,10)aretrue,giventhatgfxisareferencetoavalidGraphicsobject?
1)Therectangledrawnwillhaveatotalwidthof5pixels.
2)Therectangledrawnwillhaveatotalheightof6pixels.
3)Therectangledrawnwillhaveatotalwidthof10pixels.
4)Therectangledrawnwillhaveatotalheightof11pixels.
Q46
Giventhefollowingcode,whichcodefragments,wheninsertedattheindicatedlocation,willsucceedinmakingtheprogramdisplayabuttonspanningthewholewindowarea?
importjava.awt.*;
publicclassQ1e65{
publicstaticvoidmain(Stringargs[]){
Windowwin=newFrame();
Buttonbut=newButton("button");
//insertcodefragmenthere
win.setSize(200,200);
win.setVisible(true);
}
}
1)win.setLayout(newBorderLayout());win.add(but);
2)win.setLayout(newGridLayout(1,1));win.add(but);
3)win.setLayout(newBorderLayout());win.add(but,BorderLayout.CENTER);
4)win.add(but);
5)win.setLayout(newFlowLayout());win.add(but);
Q47
Whichmethodimplementationswillwritethegivenstringtoafilenamed"file",usingUTF8encoding?
IMPLEMENTATIONA:
publicvoidwrite(Stringmsg)throwsIOException{
FileWriterfw=newFileWriter(newFile("file"));
fw.write(msg);
fw.close();
}
IMPLEMENTATIONB:
publicvoidwrite(Stringmsg)throwsIOException{
OutputStreamWriterosw=
newOutputStreamWriter(newFileOutputStream("file"),"UTF8");
osw.write(msg);
osw.close();
}
IMPLEMENTATIONC:
publicvoidwrite(Stringmsg)throwsIOException{
FileWriterfw=newFileWriter(newFile("file"));
fw.setEncoding("UTF8");
fw.write(msg);
fw.close();
}
IMPLEMENTATIOND:
publicvoidwrite(Stringmsg)throwsIOException{
FilterWriterfw=FilterWriter(newFileWriter("file"),"UTF8");
fw.write(msg);
fw.close();
}
IMPLEMENTATIONE:
publicvoidwrite(Stringmsg)throwsIOException{
OutputStreamWriterosw=newOutputStreamWriter(
newOutputStream(newFile("file")),"UTF8"
);
osw.write(msg);
osw.close();
}
1)ImplementationA.
2)ImplementationB.
3)ImplementationC.
4)ImplementationD.
5)ImplementationE.
Q48
Whicharevalididentifiers?
1)_class
2)$value$
3)zer@
4)¥ngstr
5)2muchuq
Q49
Whatwillbetheresultofattemptingtocompileandrunthefollowingprogram?
publicclassQ28fd{
publicstaticvoidmain(Stringargs[]){
intcounter=0;
l1:
for(inti=10;i<0;i--){
l2:
intj=0;
while(j<10){
if(j>i)breakl2;
if(i==j){
counter++;
continuel1;
}
}
counter--;
}
System.out.println(counter);
}
}
1)Theprogramwillfailtocompile.
2)Theprogramwillnotterminatenormally.
3)Theprogramwillwrite10tothestandardoutput.
4)Theprogramwillwrite0tothestandardoutput.
5)Theprogramwillwrite9tothestandardoutput.
Q50
Giventhefollowinginterfacedefinition,whichdefinitionsarevalid?
interfaceI{
voidsetValue(intval);
intgetValue();
}
DEFINITIONA:
(a)classAextendsI{
intvalue;
voidsetValue(intval){value=val;}
intgetValue(){returnvalue;}
}
DEFINITIONB:
(b)interfaceBextendsI{
voidincrement();
}
DEFINITIONC:
(c)abstractclassCimplementsI{
intgetValue(){return0;}
abstractvoidincrement();
}
DEFINITIOND:
(d)interfaceDimplementsI{
voidincrement();
}
DEFINITIONE:
(e)classEimplementsI{
intvalue;
publicvoidsetValue(intval){value=val;}
}
1)DefinitionA.
2)DefinitionB.
3)DefinitionC.
4)DefinitionD.
5)DefinitionE.
Q51
Whichstatementsconcerningthemethodsnotify()andnotifyAll()aretrue?
1)InstancesofclassThreadhaveamethodcallednotify().
2)Acalltothemethodnotify()willwakethethreadthatcurrentlyownsthemonitoroftheobject.
3)Themethodnotify()issynchronized.
4)ThemethodnotifyAll()isdefinedinclassThread.
5)Whenthereismorethanonethreadwaitingtoobtainthemonitorofanobject,thereisnowaytobesurewhichthreadwillbenotifiedbythenotify()method.
Q52
Whichstatementsconcerningthecorrelationbetweentheinnerandouterinstancesofnon-staticinnerclassesaretrue?
1)Membervariablesoftheouterinstancearealwaysaccessibletoinnerinstances,regardlessoftheiraccessibilitymodifiers.
2)Membervariablesoftheouterinstancecanneverbereferredtousingonlythevariablenamewithintheinnerinstance.
3)Morethanoneinnerinstancecanbeassociatedwiththesameouterinstance.
4)Allvariablesfromtheouterinstancethatshouldbeaccessibleintheinnerinstancemustbedeclaredfinal.
5)Aclassthatisdeclaredfinalcannothaveanyinnerclasses.
Q53
Whatwillbetheresultofattemptingtocompileandrunthefollowingcode?
publicclassQ6b0c{
publicstaticvoidmain(Stringargs[]){
inti=4;
floatf=4.3;
doubled=1.8;
intc=0;
if(i==f)c++;
if(((int)(f+d))==((int)f+(int)d))c+=2;
System.out.println(c);
}
}
1)Thecodewillfailtocompile.
2)0willbewrittentothestandardoutput.
3)1willbewrittentothestandardoutput.
4)2willbewrittentothestandardoutput.
5)3willbewrittentothestandardoutput.
Q54
Whichoperatorswillalwaysevaluatealltheoperands?
1)||
2)+
3)&&
4)?:
5)%
Q55
Whichstatementsconcerningtheswitchconstructaretrue?
1)Allswitchstatementsmusthaveadefaultlabel.
2)Theremustbeexactlyonelabelforeachcodesegmentinaswitchstatement.
3)Thekeywordcontinuecanneveroccurwithinthebodyofaswitchstatement.
4)Nocaselabelmayfollowadefaultlabelwithinasingleswitchstatement.
5)Acharacterliteralcanbeusedasavalueforacaselabel.
Q56
Whichmodifiersandreturntypeswouldbevalidinthedeclarationofaworkingmain()methodforaJavastandaloneapplication?
1)private
2)final
3)static
4)int
5)abstract
Q57
Whatwillbetheappearanceofanappletwiththefollowinginit()method?
publicvoidinit(){
add(newButton("hello"));
}
1)Nothingappearsintheapplet.
2)Abuttonwillcoverthewholeareaoftheapplet.
3)Abuttonwillappearinthetopleftcorneroftheapplet.
4)Abuttonwillappear,centeredinthetopregionoftheapplet.
5)Abuttonwillappearinthecenteroftheapplet.
Q58
WhichstatementsconcerningtheeventmodeloftheAWTaretrue?
1)Atmostonelistenerofeachtypecanberegisteredwithacomponent.
2)MousemotionlistenerscanberegisteredonaListinstance.
3)ThereexistsaclassnamedContainerEventinpackagejava.awt.event.
4)ThereexistsaclassnamedMouseMotionEventinpackagejava.awt.event.
5)ThereexistsaclassnamedActionAdapterinpackagejava.awt.event.
Q59
Whichstatementsaretrue,giventhecodenewFileOutputStream("data",true)forcreatinganobjectofclassFileOutputStream?
1)FileOutputStreamhasnoconstructorsmatchingthegivenarguments.
2)AnIOExeceptionwillbethrownifafilenamed"data"alreadyexists.
3)AnIOExeceptionwillbethrownifafilenamed"data"doesnotalreadyexist.
4)Ifafilenamed"data"exists,itscontentswillberesetandoverwritten.
5)Ifafilenamed"data"exists,outputwillbeappendedtoitscurrentcontents.
Q60
Giventhefollowingcode,writealineofcodethat,wheninsertedattheindicatedlocation,willmaketheoverridingmethodinExtensioninvoketheoverriddenmethodinclassBaseonthecurrentobject.
classBase{
publicvoidprint(){
System.out.println("base");
}
}
classExtentionextendsBase{
publicvoidprint(){
System.out.println("extension");
//insertlineofimplementationhere
}
}
publicclassQ294d{
publicstaticvoidmain(Stringargs[]){
Extentionext=newExtention();
ext.print();
}
}
Fillinasinglelineofimplementation.
Q61
GiventhatfileisareferencetoaFileobjectthatrepresentsadirectory,whichcodefragmentswillsucceedinobtainingalistoftheentriesinthedirectory?
1)Vectorfilelist=((Directory)file).getList();
2)String[]filelist=file.directory();
3)Enumerationfilelist=file.contents();
4)String[]filelist=file.list();
5)Vectorfilelist=(newDirectory(file)).files();
Q62
Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五股東協(xié)議補(bǔ)充協(xié)議-股東對(duì)公司可持續(xù)發(fā)展戰(zhàn)略的承諾
- 二零二五年度跨境拖車服務(wù)及關(guān)稅代理合同
- 二零二五年度商業(yè)廣場購物中心房屋租賃與商業(yè)數(shù)據(jù)分析服務(wù)合同
- 2025年度閑置校舍租賃合同及校園內(nèi)環(huán)保能源利用合作協(xié)議
- 2025年度美容美發(fā)加盟合同解除書
- Unit 4 Did You Have a Nice Trip?單元基礎(chǔ)知識(shí)復(fù)習(xí)(含答案)
- 2025年度高校學(xué)生實(shí)習(xí)就業(yè)雙選協(xié)議書
- 二零二五年度企業(yè)員工社保權(quán)益自愿放棄協(xié)議范本
- 二零二五年度海洋地質(zhì)調(diào)查海域使用權(quán)租賃與研究開發(fā)協(xié)議
- 二零二五年度交通事故私了賠償處理協(xié)議
- 七年級(jí)數(shù)學(xué)蘇科版下冊(cè) 101 二元一次方程 課件
- 《財(cái)務(wù)風(fēng)險(xiǎn)的識(shí)別與評(píng)估管理國內(nèi)外文獻(xiàn)綜述》
- ??谑写媪糠抠I賣合同模板(范本)
- ZL50裝載機(jī)工作裝置設(shè)計(jì)
- 經(jīng)典文學(xué)作品中的女性形象研究外文文獻(xiàn)翻譯2016年
- 高爐煤氣安全知識(shí)的培訓(xùn)
- 2008 年全國高校俄語專業(yè)四級(jí)水平測試試卷
- 需求供給與均衡價(jià)格PPT課件
- 金融工程鄭振龍課后習(xí)題答案
- 時(shí)間單位換算表
- DTSD342-9N說明書(精編版)
評(píng)論
0/150
提交評(píng)論