版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
Java期末專項(xiàng)測(cè)試卷單選題(總共40題)1.單選題Theworst-timecomplexityforquicksortis_________.()(1分)A、O(1)B、O(logn)C、O(n)D、O(nlogn)E、O(n*n)答案:E解析:
暫無(wú)解析2.單選題Whatistheoutputofthefollowingcode?()
PublicclassTest{
Publicstaticvoidmain(String[]args){
NewPerson().printPerson();
NewStudent().printPerson();
}
}
ClassStudentextendsPerson{
@Override
PublicStringgetInfo(){
Return"Student";
}
}
ClassPerson{
PublicStringgetInfo(){
Return"Person";
}
PublicvoidprintPerson(){
System.out.println(getInfo());
}
}(1分)A、PersonPersonB、PersonStudentC、StduentStudentD、StudentPerson答案:B解析:
暫無(wú)解析3.單選題______________approachdividestheproblemintosubproblems,solvesthesubproblems,thencombinesthesolutionsofthesubproblemstoobtainthesolutionfortheentireproblem.Unlikethe________approach,thesubproblemsinthedivide-and-conquerapproachdon’toverlap.Asubproblemisliketheoriginalproblemwithasmallersize,soyoucanapplyrecursiontosolvetheproblem.()(1分)A、Divide-and-conquer/dynamicprogrammingB、Dynamicprogramming/divide-and-conquerC、Brutal-force/divide-and-conquerD、Backtracking/dynamicprogramming答案:A解析:
暫無(wú)解析4.單選題Analyzethefollowingcodeandchoosethebestanswer:()
PublicclassFoo{
Privateintx;
Publicstaticvoidmain(String[]args){
Foofoo=newFoo();
System.out.println(foo.x);
}
}(1分)A、Sincexisprivate,itcannotbeaccessedfromanobjectfoo.B、
SincexisdefinedintheclassFoo,itcanbeaccessedbyanymethodinsidetheclasswithoutusinganobject.Youcanwritethecodetoaccessxwithoutcreatinganobjectsuchasfoointhiscode.C、
Sincexisaninstancevariable,itcannotbedirectlyusedinsideamainmethod.However,itcanbeaccessedthroughanobjectsuchasfoointhiscode.D、Youcannotcreateaself-referencedobject;thatis,fooiscreatedinsidetheclassFoo.答案:C解析:
暫無(wú)解析5.單選題Whichofthefollowingclassescannotbeextended?()(1分)A、classA{}B、classA{privateA(){}}C、finalclassA{}D、classA{protectedA(){}}答案:C解析:
暫無(wú)解析6.單選題Thegift-wrappingalgorithmforfindingaconvexhulltakes______________time.()(1分)A、O(n)B、O(nlogn)C、O(logn)D、O(n^2)答案:D解析:
暫無(wú)解析7.單選題Thebest-timecomplexityforinsertionsortis_____________.()(1分)A、O(1)B、O(logn)C、O(n)D、O(nlogn)E、O(n*n)答案:C解析:
暫無(wú)解析8.單選題TocreateaninstanceofBigIntegerfor454,use()(1分)A、BigInteger(454);B、newBigInteger(454);C、BigInteger("454");D、newBigInteger("454");答案:D解析:
暫無(wú)解析9.單選題Supposelist1isanArrayListandlist2isaLinkedList.Bothcontains1milliondoublevalues.Analyzethefollowingcode:()
A-
For(inti=0;i<list1.size();i++)
Sum+=list1.get(i);
B-
For(inti=0;i<list2.size();i++)
Sum+=list2.get(i);(1分)A、CodefragmentArunsfasterthancodefragmentBB、CodefragmentBrunsfasterthancodefragmentAC、CodefragmentArunsasfastascodefragmentB答案:A解析:
暫無(wú)解析10.單選題SupposeTestSimpleCircleandSimpleCircleinListing9.1areintwoseparatefilesnamedTestSimpleCircle.javaandSimpleCircle.java,respectively.WhatistheoutcomeofcompilingTestsimpleCircle.javaandthenSimpleCircle.java?()(1分)A、OnlyTestSimpleCircle.javacompiles.B、OnlySimpleCircle.javacompiles.C、Bothcompilefine.D、Neithercompilessuccessfully.答案:C解析:
暫無(wú)解析11.TodeclareaninterfacenamedAwithagenerictype,use(1分)A、publicinterfaceA<E>{...}B、publicinterfaceA<E,F>{...}C、publicinterfaceA(E){...}D、publicinterfaceA(E,F){...}答案:A解析:
暫無(wú)解析12.單選題WhatisthereturnvalueforxMethod(4)aftercallingthefollowingmethod?()
StaticintxMethod(intn){
If(n==1)
Return1;
Else
Returnn+xMethod(n-1);
}(1分)A、12B、11C、10D、9答案:C解析:
暫無(wú)解析13.單選題ThetimecomplexityfortheTowersofHonoialgorithminthetextis________.()(1分)A、O(n)B、O(n^2)C、O(n^3)D、O(2^n)答案:D解析:
暫無(wú)解析14.單選題Whatisoutputofthefollowingcode:()
PublicclassTest{
Publicstaticvoidmain(String[]args){
Intlist[]={1,2,3,4,5,6};
For(inti=1;i<list.length;i++)
List[i]=list[i-1];
For(inti=0;i<list.length;i++)
System.out.print(list[i]+"");
}
}(1分)A、123456B、234566C、234561D、111111答案:D解析:
暫無(wú)解析15.單選題Therelationshipbetweenaninterfaceandtheclassthatimplementsitis()(1分)A、CompositionB、AggregationC、InheritanceD、None答案:C解析:
暫無(wú)解析16.單選題Analyzethefollowingcode.()
//Program1:
PublicclassTest{
Publicstaticvoidmain(String[]args){
Objecta1=newA();
Objecta2=newA();
System.out.println(a1.equals(a2));
}
}
ClassA{
Intx;
Publicbooleanequals(Aa){
Returnthis.x==a點(diǎn)x;
}
}
//Program2:
PublicclassTest{
Publicstaticvoidmain(String[]args){
Aa1=newA();
Aa2=newA();
System.out.println(a1.equals(a2));
}
}
ClassA{
Intx;
Publicbooleanequals(Aa){
Returnthis.x==a.x;
}
}(1分)A、Program1displaystrueandProgram2displaystrueB、Program1displaysfalseandProgram2displaystrueC、Program1displaystrueandProgram2displaysfalseD、Program1displaysfalseandProgram2displaysfalse答案:B解析:
暫無(wú)解析17.單選題Whatistheoutputofthefollowingcode?()
Int[]myList={1,2,3,4,5,6};
For(inti=myList.length-2;i>=0;i--){
MyList[i+1]=myList[i];
}
For(inte:myList)
System.out.print(e+"");(1分)A、123456B、612345C、623451D、112345E、234561答案:D解析:
暫無(wú)解析18.單選題Supposealistcontains{"red","green","red","green"}.Whatisthelistafterthefollowingcode?()
Stringelement="red";
For(inti=0;i<list.size();i++)
If(list.get(i).equals(element)){
List.remove(element);
I--;
}(1分)A、{"red","red","green"}B、{"red","green"}C、{"green","green"}D、{"green"}E、{}答案:C解析:
暫無(wú)解析19.單選題TheequalsmethodisdefinedintheObjectclass.WhichofthefollowingiscorrecttooverrideitintheStringclass?()(1分)A、publicbooleanequals(Stringother)B、publicbooleanequals(Objectother)C、publicstaticbooleanequals(Stringother)D、publicstaticbooleanequals(Objectother)答案:B解析:
暫無(wú)解析20.單選題Supposeyouchoosethefirstelementasapivotinthelist{5293840167}.Usingthepartitionalgorithminthebook,whatisthenewlistafterthepartition?()(1分)A、5293840167B、4230156798C、4213058967D、2340159867E、2340156789答案:C解析:
暫無(wú)解析21.單選題WhichofthefollowingdeclaresanabstractmethodinanabstractJavaclass?()(1分)A、publicabstractmethod();B、publicabstractvoidmethod();C、publicvoidabstractmethod();D、publicvoidmethod(){}E、publicabstractvoidmethod(){}答案:B解析:
暫無(wú)解析22.單選題WhatistheoutputofInteger.parseInt("10",2)?()(1分)A、1;B、2;C、10;D、Invalidstatement;答案:B解析:
暫無(wú)解析23.單選題Supposeyouchoosethefirstelementasapivotinthelist{5293840167}.Usingthepartitionalgorithminthebook,whatisthenewlistafterthepartition?()(1分)A、5293840167B、4230156798C、4213058967D、2340159867E、2340156789答案:C解析:
暫無(wú)解析24.單選題WhichofthefollowingareJavakeywords?()(1分)A、instanceOfB、instanceofC、castD、casting答案:B解析:
暫無(wú)解析25.單選題Thetimecomplexityforthetheclosestpairofpointsproblemusingdivide-and-conqueris________.()(1分)A、O(n)B、O(nlogn)C、O(logn)D、O(2^n)答案:B解析:
暫無(wú)解析26.單選題Analyzethefollowingcode:()
Double[]array={1,2,3};
ArrayList<Double>list=newArrayList<>(Arrays.asList(array));
System.out.println(list);(1分)A、Thecodeiscorrectanddisplays[1,2,3].B、Thecodeiscorrectanddisplays[1.0,2.0,3.0].C、Thecodehasacompileerrorbecauseanintegersuchas1isautomaticallyconvertedintoanIntegerobject,butthearrayelementtypeisDouble.D、ThecodehasacompileerrorbecauseasList(array)requiresthatthearrayelementsareobjects.答案:D解析:
暫無(wú)解析27.單選題Whatisthecorrecttermfornumbers[99]?()(1分)A、indexB、indexvariableC、indexedvariableD、arrayvariableE、array答案:C解析:
暫無(wú)解析28.單選題WhichofthedatatypesbelowcouldbeusedtostoreelementsintheirnaturalorderbasedonthecompareTomethod?()(1分)A、HashSetB、TreeSetC、LinkedHashSetD、CollectionE、Set答案:B解析:
暫無(wú)解析29.單選題Whatistheoutputofthefollowingcode:()
PublicclassTest{
Publicstaticvoidmain(String[]args){
Strings1=newString("Java");
Strings2=newString("Java");
System.out.print((s1==s2)+""+(s1.equals(s2)));
}
}(1分)A、falsefalseB、truetrueC、falsetrueD、truefalse答案:C解析:
暫無(wú)解析30.單選題IsArrayList<Integer>asubclassofArrayList<?>?()(1分)A、YesB、No答案:A解析:
暫無(wú)解析31.TodeclareaninterfacenamedAwithagenerictype,use(1分)A、publicinterfaceA<E>{...}B、publicinterfaceA<E,F>{...}C、publicinterfaceA(E){...}D、publicinterfaceA(E,F){...}答案:A解析:
暫無(wú)解析32.單選題Dothefollowingtwoprogramsproducethesameresult?()
ProgramI:
PublicclassTest{
Publicstaticvoidmain(String[]args){
Int[]list={1,2,3,4,5};
Reverse(list);
For(inti=0;i<list.length;i++)
System.out.print(list[i]+"");
}
Publicstaticvoidreverse(int[]list){
Int[]newList=newint[list.length];
For(inti=0;i<list.length;i++)
NewList[i]=list[list.length-1-i];
List=newList;
}
}
ProgramII:
PublicclassTest{
Publicstaticvoidmain(String[]args){
Int[]oldList={1,2,3,4,5};
Reverse(oldList);
For(inti=0;i<oldList.length;i++)
System.out.print(oldList[i]+"");
}
Publicstaticvoidreverse(int[]list){
Int[]newList=newint[list.length];
For(inti=0;i<list.length;i++)
NewList[i]=list[list.length-1-i];
List=newList;
}
}(1分)A、YesB、No答案:A解析:
暫無(wú)解析33.單選題Giventhefollowingcode:()
ClassC1{}
ClassC2extendsC1{}
ClassC3extendsC2{}
ClassC4extendsC1{}
C1c1=newC1();
C2c2=newC2();
C3c3=newC3();
C4c4=newC4();
Whichofthefollowingexpressionsevaluatestofalse?(1分)A、c1instanceofC1B、c2instanceofC1C、c3instanceofC1D、c4instanceofC2答案:D解析:
暫無(wú)解析34.單選題Analyzethefollowingcode.()
Importjava.util.*;
PublicclassTest{
Publicstaticvoidmain(String[]args)throwsException{
TreeSet<String>set=newTreeSet<>();
Set.add("Red");
Set.add("Yellow");
Set.add("Green");
Set.add("Blue");
SortedSettemp=set.headSet("Purple");
System.out.println(temp.first());
}
}(1分)A、TheprogramdisplaysRedB、TheprogramdisplaysBlueC、TheprogramdisplaysGreenD、TheprogramdisplaysYellowE、TheprogramdisplaysPurple答案:B解析:
暫無(wú)解析35.單選題Analyzethefollowingcode.Whichofthefollowingstatementsiscorrect?()
PublicclassTest{
Publicstaticvoidmain(String[]args){
Numberx=newInteger(3);
System.out.println(Value());
System.out.println(pareTo(newInteger(4)));
}
}(1分)A、TheprogramhasacompileerrorbecauseanIntegerinstancecannotbeassignedtoaNumbervariable.B、TheprogramhasacompileerrorbecauseintValueisanabstractmethodinNumber.C、TheprogramhasacompileerrorbecausexdoesnothavethecompareTomethod.D、Theprogramcompilesandrunsfine.答案:C解析:
暫無(wú)解析36.AssumeCalendarcalendar=newGregorianCalendar().__________returnsthemonthoftheyear.()(1分)A、calendar.get(Calendar.MONTH);B、calendar.get(Calendar.MONTH_OF_YEAR);C、calendar.get(Calendar.WEEK_OF_MONTH);D、calendar.get(Calendar.WEEK_OF_YEAR);答案:A解析:
暫無(wú)解析37.單選題Topreventaclassfrombeinginstantiated,_____________________()(1分)A、don'tuseanymodifiersontheconstructor.B、usethepublicmodifierontheconstructor.C、usetheprivatemodifierontheconstructor.D、usethestaticmodifierontheconstructor.答案:C解析:
暫無(wú)解析38.單選題The"lessthanorequalto"comparisonoperatorinJavais__________.()(1分)A、<B、<=C、=<D、<<E、!=答案:B解析:
暫無(wú)解析39.單選題Whatistheoutputofthefollowingcode?()
PublicclassTest{
Publicstaticvoidmain(String[]args){
Java.math.BigIntegerx=newjava.math.BigInteger("3");
Java.math.BigIntegery=newjava.math.BigInteger("7");
X.add(y);
System.out.println(x);
}
}(1分)A、3B、4C、10D、11答案:A解析:
暫無(wú)解析40.單選題15.AssumeCalendarcalendar=newGregorianCalendar().__________returnsthenumberofdaysinamonth.()(1分)A、calendar.get(Calendar.MONTH)B、calendar.get(Calendar.MONTH_OF_YEAR)C、calendar.get(Calendar.WEEK_OF_MONTH)D、calendar.get(Calendar.WEEK_OF_YEAR)E、calendar.getActualMaximum(Calendar.DAY_OF_MONTH)答案:E解析:
暫無(wú)解析多選題(總共40題)1.多選題SupposeArrayList<Double>list=newArrayList<>().Whichofthefollowingstatementsarecorrect?()(1分)A、list.add(5.5);//5.5isautomaticallyconvertedtonewDouble(5.5)B、list.add(3.0);//3.0isautomaticallyconvertedtonewDouble(3.0)C、DoubledoubleObject=list.get(0);//NocastingisneededD、doubled=list.get(1);//Automaticallyconvertedtodouble答案:ABCD解析:
暫無(wú)解析2.多選題TheGeometricObjectandCircleclassesaredefinedinthischapter.Analyzethefollowingcode.Whichstatementsarecorrect?()
PublicclassTest{
Publicstaticvoidmain(String[]args){
GeometricObjectx=newCircle(3);
GeometricObjecty=(Circle)(x.clone());
System.out.println(x);
System.out.println(y);
}
}(1分)A、Theprogramhasacompileerrorbecausetheclone()methodisprotectedintheObjectclass.B、Afteryouoverridetheclone()methodandmakeitpublicintheCircleclass,theproblemcancompileandrunjustfine,butyisnullifCircledoesnotimplementtheCloneableinterface.C、ToenableaCircleobjecttobecloned,theCircleclasshastooverridetheclone()methodandimplementthejava.lang.Cloneableinterface.D、IfGeometricObjectimplementsCloneableandCircleoverridestheclone()method,theclone()methodwillworkfinetocloneCircleobjects.答案:ABCD解析:
暫無(wú)解析3.WhichofthefollowingmethodsareintheCollectioninterface?(1分)A、add(o:E)B、addAll(c:Collection<?extendsE>)C、contains(o:Object):booleanD、containsAll(c:Collection<?>):boolean答案:ABCD解析:
暫無(wú)解析4.多選題Whichofthefollowingstatementsaretrue?()(1分)A、java.util.Listinheritsallthemethodsfromjava.util.Collection.Additionally,itcontainsnewmethodsformanipulatingalist.B、TheAbstractListclassprovidesapartialimplementationfortheListinterface.C、ArrayListisaconcreteimplementationofListusinganarray.D、LinkedListisaconcreteimplementationofListusingalinkedlist.LinkedListcontainsallthemethodsinListandadditionalnewmethodsformanipulatingalinkedlist.E、ListIteratorisasubinterfaceofIteratoranditprovidesthemethodstosupportbi-directionaltraversalofalist.答案:ABCDE解析:
暫無(wú)解析5.多選題Whichofthefollowingdatatypeshaveiterators?()(1分)A、HashSetB、TreeSetC、ArrayListD、LinkedListE、LinkedHashSet答案:ABCDE解析:
暫無(wú)解析6.多選題WhichofthefollowingarecorrectmethodsinMap?()(1分)A、containsKey(Objectkey)B、containsValue(Objectvalue)C、remove(Objectkey)D、remove(intindex)E、isEmpty()答案:ABCE解析:
暫無(wú)解析7.多選題Theelementsin________aresorted.()(1分)A、TreeSetB、ListC、TreeMapD、HashSetE、LinkedHashSet答案:AC解析:
暫無(wú)解析8.多選題Howcanyouinitializeanarrayoftwocharactersto'a'and'b'?()(1分)A、char[]charArray=newchar[2];charArray={'a','b'};B、char[2]charArray={'a','b'};C、char[]charArray={'a','b'};D、char[]charArray=newchar[]{'a','b'};答案:CD解析:
暫無(wú)解析9.多選題FillinthecodetocompletethefollowingmethodforcomputingaFibonaccinumber.()
Publicstaticlongfib(longindex){
If(index==0)//Basecase
Return0;
Elseif(index==1)//Basecase
Return1;
Else//Reductionandrecursivecalls
Return__________________;
}(1分)A、fib(index-1)B、fib(index-2)C、fib(index-1)+fib(index-2)D、fib(index-2)+fib(index-1)答案:CD解析:
暫無(wú)解析10.多選題WhichofthefollowingcomplexityisO(nlogn)?()(1分)A、300n+400n*nB、23nlogn+50C、45n+45nlogn+503D、n*n*n+nlogn答案:BC解析:
暫無(wú)解析11.多選題YoucanusethemethodsintheArraysclassto()(1分)A、findthemaximumobjectinanarraybasedonthecompareTomethod.B、findthemaximumobjectinanarrayusingaComparatorobject.C、sortanarray.D、shuffleanarray.E、doabinarysearchonanarray.答案:CE解析:
暫無(wú)解析12.多選題Whatiscorrectaboutapivot?()(1分)A、Apivotdividesalistintotwosublistsofequalsize.B、Apivotcanbechosenarbitrarily.C、Apivotdividesalistintotwosublists,theelementsinthefirstlistarenolargerthanthepivotandtheelementsinthesecondlistarelargerthanthepivot.D、Youshouldalwayschooseapivotthatdividesthelistevenly.答案:BC解析:
暫無(wú)解析13.多選題Toobtainthedistancebetweenthepoints(40,50)and(5.5,4.4),use_________.()(1分)A、distance(40,50,5.5,4.4)B、newPoint2D(40,50).distance(5.5,4.4)C、newPoint2D(40,50).distance(newPoint2D(5.5,4.4))D、newPoint2D(5.5,4.4).distance(40,50)E、newPoint2D(5.5,4.4).distance(newPoint2D(40,50))答案:BCDE解析:
暫無(wú)解析14.多選題SupposeListlist=newArrayList().Whichofthefollowingoperationsarecorrect?()(1分)A、list.add("Red");B、list.add(newInteger(100));C、list.add(newjava.util.Date());D、list.add(newArrayList());答案:ABCD解析:
暫無(wú)解析15.多選題SupposeListlist=newArrayList().Whichofthefollowingoperationsarecorrect?()(1分)A、list.add("Red");B、list.add(newInteger(100));C、list.add(newjava.util.Date());D、list.add(newArrayList());答案:ABCD解析:
暫無(wú)解析16.多選題Whichofthefollowingstatementswillconvertastringsintoiofinttype?()(1分)A、i=Integer.parseInt(s);B、i=(newInteger(s)).intValue();C、i=Integer.valueOf(s).intValue();D、i=Integer.valueOf(s);E、i=(int)(Double)parseDouble(s));答案:ABCDE解析:
暫無(wú)解析17.多選題Whichofthefollowingstatementsaretrue?()(1分)A、AnArrayListcangrowautomatically.B、AnArrayListcanshrinkautomatically.C、YoucanreducethecapacityofanArrayListbyinvokingthetrimToSize()methodonthelist.D、YoucanreducethecapacityofaLinkedListbyinvokingthetrimToSize()methodonthelist.答案:AC解析:
暫無(wú)解析18.多選題Whichofthefollowingisincorrect?()(1分)A、int[]a=newint[2];B、inta[]=newint[2];C、int[]a=newint(2);D、inta=newint[2];E、inta()=newint[2];答案:CDE解析:
暫無(wú)解析19.多選題Whichofthefollowingstatementsiscorrect?()(1分)A、Genericscanhelpdetecttypeerrorsatcompiletime,thusmakeprogramsmorerobust.B、Genericscanmakeprogramseasytoread.C、Genericscanavoidcumbersomecastings.D、Genericscanmakeprogramsrunfaster.答案:ABC解析:
暫無(wú)解析20.多選題WhichofthefollowingcomplexityisO(nlogn)?()(1分)A、300n+400n*nB、23nlogn+50C、45n+45nlogn+503D、n*n*n+nlogn答案:BC解析:
暫無(wú)解析21.多選題Analyzethefollowingcode:()
ArrayList<String>list=newArrayList<String>();
List.add("Beijing");
List.add("Tokyo");
List.add("Shanghai");
List.set(3,"HongKong");(1分)A、Thelastlineinthecodecausesaruntimeerrorbecausethereisnoelementatindex3inthearraylist.B、Thelastlineinthecodehasacompileerrorbecausethereisnoelementatindex3inthearraylist.C、Ifyoureplacethelastlinebylist.add(3,"HongKong"),thecodewillcompileandrunfine.D、Ifyoureplacethelastlinebylist.add(4,"HongKong"),thecodewillcompileandrunfine.答案:AC解析:
暫無(wú)解析22.多選題Whichofthefollowingstatementsaretrue?()(1分)A、java.util.Listinheritsallthemethodsfromjava.util.Collection.Additionally,itcontainsnewmethodsformanipulatingalist.B、TheAbstractListclassprovidesapartialimplementationfortheListinterface.C、ArrayListisaconcreteimplementationofListusinganarray.D、LinkedListisaconcreteimplementationofListusingalinkedlist.LinkedListcontainsallthemethodsinListandadditionalnewmethodsformanipulatingalinkedlist.E、ListIteratorisasubinterfaceofIteratoranditprovidesthemethodstosupportbi-directionaltraversalofalist.答案:ABCDE解析:
暫無(wú)解析23.多選題ToaddBigIntegerb1tob2,youwrite_________.()(1分)A、b1.add(b2);B、b2.add(b1);C、b2=b1.add(b2);D、b2=b2.add(b1);E、b1=b2.add(b1);答案:CD解析:
暫無(wú)解析24.多選題Whichofthefollowingarevalidspecifiersfortheprintfstatement?()(1分)A、%4cB、%10bC、%6dD、%8.2dE、%10.2e答案:ABCE解析:
暫無(wú)解析25.多選題Analyzethefollowingcode:()
PublicclassAextendsB{
}
ClassB{
PublicB(Strings){
}
}(1分)A、TheprogramhasacompileerrorbecauseAdoesnothaveadefaultconstructor.B、TheprogramhasacompileerrorbecausethedefaultconstructorofAinvokesthedefaultconstructorofB;butBdoesnothaveadefaultconstructor.C、TheprogramwouldcompilefineifyouaddthefollowingconstructorintoA-A(Strings){}D、TheprogramwouldcompilefineifyouaddthefollowingconstructorintoA-A(Strings){super(s);}答案:BD解析:
暫無(wú)解析26.多選題Whichofthefollowingis/arecorrect?()(1分)A、Aconstructormaybestatic.B、Aconstructormaybeprivate.C、Aconstructormayinvokeastaticmethod.D、Aconstructormayinvokeanoverloadedconstructor.E、Aconstructorinvokesitssuperclassno-argconstructorbydefaultifaconstructordoesnotinvokeanoverloadedconstructororitssuperclassconstructor.答案:BCDE解析:
暫無(wú)解析27.多選題Giventhefollowingcode,findthecompileerror.()
PublicclassTest{
Publicstaticvoidmain(String[]args){
M(newGraduateStudent());
M(newStudent());
M(newPerson());
M(newObject());
}
Publicstaticvoidm(Studentx){
System.out.println(x.toString());
}
}
ClassGraduateStudentextendsStudent{
}
ClassStudentextendsPerson{
@Override
PublicStringtoString(){
Return"Student";
}
}
ClassPersonextendsObject{
@Override
PublicStringtoString(){
Return"Person";
}
}(1分)A、m(newGraduateStudent())causesanerrorB、m(newStudent())causesanerrorC、m(newPerson())causesanerrorD、m(newObject())causesanerror答案:CD解析:
暫無(wú)解析28.多選題YoucanusethemethodsintheCollectionsclassto()(1分)A、findthemaximumobjectinacollectionbasedonthecompareTomethod.B、findthemaximumobjectinacollectionusingaComparatorobject.C、sortacollection.D、shuffleacollection.E、doabinarysearchonacollection.答案:AB解析:
暫無(wú)解析29.WhichofthefollowingmethodsareintheCollectioninterface?(1分)A、add(o:E)B、addAll(c:Collection<?extendsE>)C、contains(o:Object):booleanD、containsAll(c:Collection<?>):boolean答案:ABCD解析:
暫無(wú)解析30.多選題Whichofthefollowingstatementsistrue?()
(1分)A、Ifyoucompileaninterfacewithouterrors,a.classfileiscreatedfortheinterface.B、Ifyoucompileaclasswithouterrorsbutwithwarnings,a.classfileiscreated.C、Ifyoucompileaclasswitherrors,a.classfileiscreatedfortheclass.D、Ifyoucompileaninterfacewithouterrors,butwithwarnings,a.classfileiscreatedfortheinterface.E、classfileiscreatedforeachJavaclassandinterface.Butifithasacompileerror,no.classfileiscreated.答案:ABD解析:
暫無(wú)解析31.多選題Whichofthefollowingstatementsaretrue?(1分)A、TheComparableinterfacecontainsthecompareTomethodwiththesignature"publicintcompareTo(E)".B、TheComparatorinterfacecontainsthecomparemethodwiththesignature"publicintcompare(
E,E)".C、AComparableobjectcancomparethisobjectwiththeotherobject.D、AComparatorobjectcontainsthecomparemethodthatcomparestwoobjects.答案:ABCD解析:
暫無(wú)解析32.多選題Whichofthefollowingstatementsaretrue?()(1分)A、Adefaultconstructorisprovidedautomaticallyifnoconstructorsareexplicitlydeclaredintheclass.B、Atleastoneconstructormustalwaysbedefinedexplicitly.C、Everyclasshasadefaultconstructor.D、Thedefaultconstructorisano-argconstructor
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年預(yù)購(gòu)商品房合同3篇
- 2025年度oem服裝加工與品牌授權(quán)合同范本3篇
- 2024年標(biāo)準(zhǔn)版商品交易協(xié)議書版B版
- 2024年金融教育與普及項(xiàng)目合同3篇
- 2025年度特色餐廳品牌授權(quán)合作協(xié)議3篇
- 2024幼兒園清潔服務(wù)租賃合同
- 2024年離婚協(xié)議書規(guī)范格式3篇
- 2024年礦石物流承運(yùn)協(xié)議標(biāo)準(zhǔn)模板版B版
- 2024購(gòu)房合同樣書
- 2024年高頻交易系統(tǒng)開發(fā)與授權(quán)合同
- 2024年七年級(jí)語(yǔ)文上學(xué)期期末作文題目及范文匯編
- 云南省昆明市五華區(qū)2023-2024學(xué)年九年級(jí)上學(xué)期期末英語(yǔ)試卷+
- 2023年生產(chǎn)運(yùn)營(yíng)副總經(jīng)理年度總結(jié)及下一年計(jì)劃
- 2023年中考語(yǔ)文標(biāo)點(diǎn)符號(hào)(頓號(hào))練習(xí)(含答案)
- 施工圖審查招標(biāo)文件范文
- 新課標(biāo)人教版數(shù)學(xué)三年級(jí)上冊(cè)第八單元《分?jǐn)?shù)的初步認(rèn)識(shí)》教材解讀
- (人教版2019)數(shù)學(xué)必修第一冊(cè) 第三章 函數(shù)的概念與性質(zhì) 復(fù)習(xí)課件
- 布袋式除塵器制造工序檢驗(yàn)規(guī)定
- 艾滋病、梅毒和乙肝檢測(cè)方法介紹及選擇
- 水資源稅納稅申報(bào)表附表
- MF47萬(wàn)用表組裝與檢測(cè)教學(xué)教案
評(píng)論
0/150
提交評(píng)論