Java期末專項測試卷_第1頁
Java期末專項測試卷_第2頁
Java期末專項測試卷_第3頁
Java期末專項測試卷_第4頁
Java期末專項測試卷_第5頁
已閱讀5頁,還剩18頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

Java期末專項測試卷單選題(總共40題)1.單選題Analyzethefollowingcode:()

PublicclassTest{

Publicstaticvoidmain(String[]args){

Int[]x={1,2,3,4};

Int[]y=x;

X=newint[2];

For(inti=0;i<y.length;i++)

System.out.print(y[i]+"");

}

}(1分)A、Theprogramdisplays1234B、Theprogramdisplays00C、Theprogramdisplays0034D、Theprogramdisplays0000答案:A解析:

暫無解析2.單選題Whatistheoutputofthefollowingcode?()

ArrayList<String>list=newArrayList<String>();

Strings1=newString("Java");

Strings2=newString("Java");

List.add(s1);

List.add(s2);

System.out.println((list.get(0)==list.get(1))+""+(list.get(0)).equals(list.get(1)));(1分)A、truefalseB、falsetrueC、truetrueD、falsefalse答案:B解析:

暫無解析3.單選題Thefollowingprogramdisplays__________.()

PublicclassTest{

Publicstaticvoidmain(String[]args){

Strings="Java";

StringBuilderbuffer=newStringBuilder(s);

Change(s);

System.out.println(s);

}

Privatestaticvoidchange(Strings){

S=s+"andHTML";

}

}(1分)A、JavaB、JavaandHTMLC、andHTMLD、nothingisdisplayed答案:A解析:

暫無解析4.單選題Whichofthefollowingcanbeplacedintheblanklineinthefollowingcode?()

PublicclassTest{

Privateintid;

Publicvoidm1(){

_____.id=45;

}

}(1分)A、thisB、Test答案:A解析:

暫無解析5.單選題Analyzethefollowingcode:()

PublicclassTest{

Publicstaticvoidmain(String[]args){

Strings=newString("WelcometoJava");

Objecto=s;

Stringd=(String)o;

}

}(1分)A、WhenassigningstooinObjecto=s,anewobjectiscreated.B、WhencastingotosinStringd=(String)o,anewobjectiscreated.C、WhencastingotosinStringd=(String)o,thecontentsofoischanged.D、s,o,anddreferencethesameStringobject.答案:C解析:

暫無解析6.單選題Assumeanemployeecanworkforonlyonecompany.WhatisthebestsuitablerelationshipbetweenCompanyandEmployee?()(1分)A、NoneB、AggregationC、InheritanceD、Composition答案:D解析:

暫無解析7.單選題Whichistheadvantageofencapsulation?()(1分)A、Onlypublicmethodsareneeded.B、Makingtheclassfinalcausesnoconsequentialchangestoothercode.C、Itchangestheimplementationwithoutchangingaclass'scontractandcausesnoconsequentialchangestoothercode.D、Itchangesaclass'scontractwithoutchangingtheimplementationandcausesnoconsequentialchangestoothercode.答案:C解析:

暫無解析8.單選題Thetimecomplexityforthetheclosestpairofpointsproblemusingdivide-and-conqueris________.()(1分)A、O(n)B、O(nlogn)C、O(logn)D、O(2^n)答案:B解析:

暫無解析9.單選題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解析:

暫無解析10.單選題Amethodthatisassociatedwithanindividualobjectiscalled__________.()(1分)A、astaticmethodB、aclassmethodC、aninstancemethodD、anobjectmethod答案:C解析:

暫無解析11.單選題Analyzethefollowingcode.()

Importjava.util.*;

PublicclassTest{

Publicstaticvoidmain(String[]args)throwsException{

TreeSet<String>set=newTreeSet<>();

Set.add("Red");

Set.add("Green");

Set.add("Blue");

System.out.println(set.last());

}

}(1分)A、TheprogramdisplaysRedB、TheprogramdisplaysBlueC、TheprogramdisplaysGreenD、TheprogrammaydisplayRed,Blue,orGreen.E、Theprogramcannotcompile,becausethelast()methodisnotdefinedinSet.答案:A解析:

暫無解析12.單選題Thejava.util.Calendarandjava.util.GregorianCalendarclassesareintroducedinChapter11.Analyzethefollowingcode.Whichofthefollowingstatementsiscorrect?()

1importjava.util.*;

2publicclassTest{

3publicstaticvoidmain(String[]args){

4Calendar[]calendars=newCalendar[10];

5calendars[0]=newCalendar();

6calendars[1]=newGregorianCalendar();

7}

8}(1分)A、TheprogramhasacompileerroronLine4becausejava.util.Calendarisanabstractclass.B、TheprogramhasacompileerroronLine5becausejava.util.Calendarisanabstractclass.C、TheprogramhasacompileerroronLine6becauseCalendar[1]isnotofaGregorianCalendartype.D、Theprogramhasnocompileerrors答案:B解析:

暫無解析13.單選題ThetimecomplexityfortherecursiveFibnaccialgorithminthetextis________.()(1分)A、O(nlogn)B、O(n^2)C、O(logn)D、O(2^n)答案:D解析:

暫無解析14.單選題Thejava.util.Calendarandjava.util.GregorianCalendarclassesareintroducedinChapter11.Analyzethefollowingcode.Whichofthefollowingstatementsiscorrect?()

1importjava.util.*;

2publicclassTest{

3publicstaticvoidmain(String[]args){

4Calendar[]calendars=newCalendar[10];

5calendars[0]=newCalendar();

6calendars[1]=newGregorianCalendar();

7}

8}(1分)A、TheprogramhasacompileerroronLine4becausejava.util.Calendarisanabstractclass.B、TheprogramhasacompileerroronLine5becausejava.util.Calendarisanabstractclass.C、TheprogramhasacompileerroronLine6becauseCalendar[1]isnotofaGregorianCalendartype.D、Theprogramhasnocompileerrors答案:B解析:

暫無解析15.單選題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解析:

暫無解析16.單選題Analyzethefollowingcode:()

PublicclassTest{

Publicstaticvoidmain(String[]args){

Doubleradius;

FinaldoublePI=3.15169;

Doublearea=radius*radius*PI;

System.out.println("Areais"+area);

}

}(1分)A、Theprogramhascompileerrorsbecausethevariableradiusisnotinitialized.B、TheprogramhasacompileerrorbecauseaconstantPIisdefinedinsideamethod.C、Theprogramhasnocompileerrorsbutwillgetaruntimeerrorbecauseradiusisnotinitialized.D、Theprogramcompilesandrunsfine.答案:A解析:

暫無解析17.單選題Whenyoupassanarraytoamethod,themethodreceives__________.()(1分)A、acopyofthearrayB、acopyofthefirstelementC、thereferenceofthearrayD、thelengthofthearray答案:C解析:

暫無解析18.單選題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解析:

暫無解析19.單選題Analyzethefollowingcode.()

//Program1:

PublicclassTest{

Publicstaticvoidmain(String[]args){

Objecta1=newA();

Objecta2=newA();

System.out.println(a1.equals(a2));

}

}

ClassA{

Intx;

Publicbooleanequals(Aa){

Returnthis.x==a點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解析:

暫無解析20.單選題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解析:

暫無解析21.單選題Analyzethefollowingcode:()

PublicclassTest{

Publicstaticvoidmain(String[]args){

Int[]x={1,2,3,4,5};

XMethod(x,5);

}

PublicstaticvoidxMethod(int[]x,intlength){

System.out.print(""+x[length-1]);

XMethod(x,length-1);

}

}(1分)A、Theprogramdisplays12346.B、Theprogramdisplays12345andthenraisesanArrayIndexOutOfBoundsException.C、Theprogramdisplays54321.D、Theprogramdisplays54321andthenraisesanArrayIndexOutOfBoundsException.答案:D解析:

暫無解析22.單選題AssumeStringBuilderstrBufis"ABCDEFG",afterinvoking_________,strBufcontains"AEFG".()(1分)A、strBuf.delete(0,3)B、strBuf.delete(1,3)C、strBuf.delete(1,4)D、strBuf.delete(2,4)答案:C解析:

暫無解析23.單選題Youcandeclaretwovariableswiththesamenamein__________.()(1分)A、amethodoneasaformalparameterandtheotherasalocalvariableB、ablockC、twonestedblocksinamethod(twonestedblocksmeansonebeinginsidetheother)D、differentmethodsinaclass答案:D解析:

暫無解析24.單選題Whatistheoutputforthefollowingcode?()

Importjava.util.*;

PublicclassTest{

Publicstaticvoidmain(String[]args){

Set<A>set=newHashSet<>();

Set.add(newA());

Set.add(newA());

Set.add(newA());

Set.add(newA());

System.out.println(set);

}

}

ClassA{

Intr=1;

PublicStringtoString(){

Returnr+"";

}

PublicinthashCode(){

Returnr;

}

}(1分)A、[1]B、[1,1]C、[1,1,1]D、[1,1,1,1]答案:D解析:

暫無解析25.單選題SupposeArrayListxcontainstwostrings[Beijing,Singapore].Whichofthefollowingmethodswillcausethelisttobecome[Beijing,Chicago,Singapore]?()(1分)A、x.add("Chicago")B、x.add(0,"Chicago")C、x.add(1,"Chicago")D、x.add(2,"Chicago")答案:C解析:

暫無解析26.單選題O(1)is________.()(1分)A、constanttimeB、logarithmictimeC、lineartimeD、log-lineartime答案:A解析:

暫無解析27.單選題Theaverage-timecomplexityforheapsortis_________()(1分)A、O(1)B、O(logn)C、O(n)D、O(nlogn)E、O(n*n)答案:D解析:

暫無解析28.單選題Ifyoudeclareanarraydouble[]list={3.4,2.0,3.5,5.5},thehighestindexinarraylistis__________.()(1分)A、0B、1C、2D、3E、4答案:D解析:

暫無解析29.單選題IsArrayList<Number>asubclassofArrayList<?extendsNumber>?()(1分)A、YesB、No答案:A解析:

暫無解析30.單選題Whatisdisplayedbythefollowingcode?()

String[]tokens="A,B;C;D".split("[,;]");

For(inti=0;i<tokens.length;i++)

System.out.print(tokens[i]+"");(1分)A、AB;C;DB、ABCDC、ABC;DD、AB;C;D答案:B解析:

暫無解析31.單選題Supposesets1is[1,2,5]andsets2is[2,3,6].Afters1.removeAll(s2),s1is__________.()(1分)A、[1,2,2,3,5,6]B、[1,2,3,5,6]C、[1,5]D、[2]答案:C解析:

暫無解析32.單選題WhatistheoutputofrunningclassC?()

ClassA{

PublicA(){

System.out.println(

"ThedefaultconstructorofAisinvoked");

}

}

ClassBextendsA{

PublicB(){

System.out.println(

"ThedefaultconstructorofBisinvoked");

}

}

PublicclassC{

Publicstaticvoidmain(String[]args){

Bb=newB();

}

}(1分)A、NothingdisplayedB、"ThedefaultconstructorofBisinvoked"C、"ThedefaultconstructorofAisinvoked"followedby"ThedefaultconstructorofBisinvoked"D、"ThedefaultconstructorofBisinvoked"followedby"ThedefaultconstructorofAisinvoked"E、"ThedefaultconstructorofAisinvoked"答案:C解析:

暫無解析33.TodeclareaninterfacenamedAwithtwogenerictypes,use(1分)A、publicinterfaceA<E>{...}B、publicinterfaceA<E,F>{...}C、publicinterfaceA(E){...}D、publicinterfaceA(E,F){...}答案:B解析:

暫無解析34.單選題The__________algorithmdoesnotcomparekeys.()(1分)A、quicksortB、mergesortC、heapsortD、radixsort答案:D解析:

暫無解析35.單選題AlltheconcreteclassesintheJavaCollectionsFrameworkimplement_____________.()(1分)A、theCloneableinterfaceB、theSerializableinterfacesC、theComparableinterfaceD、theComparatorinterface答案:B解析:

暫無解析36.單選題Youcanuseafor-eachlooptotraverseallelementsinacontainerobjectthatimplements_____.()(1分)A、IteratorB、CollectionC、IterableD、ArrayList答案:C解析:

暫無解析37.單選題Whatistheoutputofthefollowingcode?()

PublicclassTest{

Publicstaticvoidmain(String[]args){

Strings1="WelcometoJava!";

Strings2="WelcometoJava!";

If(s1==s2)

System.out.println("s1ands2referencetothesameStringobject");

Else

System.out.println("s1ands2referencetodifferentStringobjects");

}

}(1分)A、s1ands2referencetothesameStringobjectB、s1ands2referencetodifferentStringobjects答案:A解析:

暫無解析38.單選題Aninputthatresultsintheshortestexecutiontimeiscalledthe_____________.()(1分)A、best-caseinputB、worst-caseinputC、average-caseinput答案:A解析:

暫無解析39.單選題Thekeyword__________isrequiredtodeclareaclass.()(1分)A、publicB、privateC、classD、Alloftheabove.答案:C解析:

暫無解析40.單選題TocreateagenerictypeboundedbyNumber,use()(1分)A、<EextendsNumber>B、<EextendsObject>C、<E>D、<EextendsInteger>答案:A解析:

暫無解析多選題(總共40題)1.多選題__________returnsastring.()(1分)A、String.valueOf(123)B、String.valueOf(12.53)C、String.valueOf(false)D、String.valueOf(newchar[]{'a','b','c'})答案:ABCD解析:

暫無解析2.多選題WhichofthefollowingcanbeusedtoreplaceYYYYYYYYinthefollowingcode?()

PublicclassWildCardDemo3{

Publicstaticvoidmain(String[]args){

GenericStack<String>stack1=newGenericStack<>();

GenericStack<Object>stack2=newGenericStack<>();

Stack2.push("Java");

Stack2.push(2);

Stack1.push("Sun");

Add(stack1,stack2);

WildCardDemo2.print(stack2);

}

Publicstatic<T>voidYYYYYYYY{

While(!stack1.isEmpty())

Stack2.push(stack1.pop());

}

}(1分)A、add(GenericStack<T>stack1,GenericStack<T>stack2)B、add(GenericStack<?extendsT>stack1,GenericStack<T>stack2)C、add(GenericStack<T>stack1,GenericStack<?superT>stack2)D、add(GenericStack<T>stack1,GenericStack<Object>stack2)答案:BC解析:

暫無解析3.多選題Whichofthefollowingstatementsaretrue?()(1分)A、Asubclassisasubsetofasuperclass.B、Asubclassisusuallyextendedtocontainmorefunctionsandmoredetailedinformationthanitssuperclass.C、"classAextendsB"meansAisasubclassofBD、"classAextendsB"meansBisasubclassofA答案:BC解析:

暫無解析4.多選題Thejava.util.Dateclassisintroducedinthissection.Analyzethefollowingcodeandchoosethebestanswer:WhichofthefollowingcodeinIorII,orbothcreatesanobjectoftheDateclass:()

(I)

PublicclassTest{

PublicTest(){

Newjava.util.Date();

}

}

(II)

PublicclassTest{

PublicTest(){

Java.util.Datedate=newjava.util.Date();

}

}(1分)A、IB、IIC、Neither答案:AB解析:

暫無解析5.多選題YoucanusethemethodsintheArraysclassto()(1分)A、findthemaximumobjectinanarraybasedonthecompareTomethod.B、findthemaximumobjectinanarrayusingaComparatorobject.C、sortanarray.D、shuffleanarray.E、doabinarysearchonanarray.答案:CE解析:

暫無解析6.多選題Whichofthefollowingstatementsiscorrect?()(1分)A、Integer.parseInt("12",2);B、Integer.parseInt(100);C、Integer.parseInt("100");D、Integer.parseInt(100,16);E、Integer.parseInt("345",8);答案:CE解析:

暫無解析7.多選題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解析:

暫無解析8.多選題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解析:

暫無解析9.多選題Whichofthefollowingstatementsiscorrect?()(1分)A、Comparable<String>c=newString("abc");B、Comparable<String>c="abc";C、Comparable<String>c=newDate();D、Comparable<Object>c=newDate();答案:AB解析:

暫無解析10.多選題SupposeArrayListxcontainstwostrings[Beijing,Singapore].Whichofthefollowingmethodwillcausethelisttobecome[Beijing]?()(1分)A、x.remove("Singapore")B、x.remove(0)C、x.remove(1)D、x.remove(2)答案:AC解析:

暫無解析11.Whichofthefollowingstatementsregardingabstractmethodsistrue?()(1分)A、Abstractclasseshaveconstructors.B、Aclassthatcontainsabstractmethodsmustbeabstract.C、Itispossibletodeclareanabstractclassthatcontainsnoabstractmethods.D、Anabstractmethodcannotbecontainedinanonabstractclass.E、Adatafieldcanbedeclaredabstract.答案:ABCD解析:

暫無解析12.多選題Supposes1ands2aretwostrings.Whichofthefollowingstatementsorexpressionsareincorrect?()(1分)A、Strings=newString("newstring");B、Strings3=s1+s2C、s1>=s2D、inti=s1.lengthE、s1.charAt(0)='5'答案:CDE解析:

暫無解析13.多選題Whichofthefollowingstatementsarecorrect?()(1分)A、WhencreatingaRandomobject,youhavetospecifytheseedorusethedefaultseed.B、IftwoRandomobjectshavethesameseed,thesequenceoftherandomnumbersobtainedfromthesetwoobjectsareidentical.C、ThenextInt()methodintheRandomclassreturnsthenextrandomintvalue.D、ThenextDouble()methodintheRandomclassreturnsthenextrandomdoublevalue.答案:ABCD解析:

暫無解析14.多選題Whichofthefollowingstatementsiscorrect?()(1分)A、Integeri=4.5;B、Doublei=4.5;C、Objecti=4.5;D、Numberi=4.5;答案:BCD解析:

暫無解析15.多選題Whichofthefollowingarevalidspecifiersfortheprintfstatement?()(1分)A、%4cB、%10bC、%6dD、%8.2dE、%10.2e答案:ABCE解析:

暫無解析16.多選題InJDK1.5,analyzethefollowingcode.()

Line1:Integer[]intArray={1,2,3};

Line2:inti=intArray[0]+intArray[1];

Line3:intj=i+intArray[2];

Line4:doubled=intArray[0];(1分)A、ItisOKtoassign1,2,3toanarrayofIntegerobjectsinJDK1.5.B、ItisOKtoautomaticallyconvertanIntegerobjecttoanintvalueinLine2.C、ItisOKtomixanintvaluewithanIntegerobjectinanexpressioninLine3.D、Line4isOK.AnintvaluefromintArray[0]objectisassignedtoadoublevariabled點答案:ABCD解析:

暫無解析17.多選題WhichofthefollowingisapossibleoutputfrominvokingMath.random()?()(1分)A、3.43B、0.5C、0.0D、1.0答案:BC解析:

暫無解析18.多選題Whichofthefollowingmethodsareinjava.util.List?()(1分)A、add(intindex,Eelement)B、get(intindex)C、set(intindex,Eelement)D、remove(intindex)E、subList(intfromIndex,inttoIndex)答案:ABCDE解析:

暫無解析19.多選題Analyzethefollowingcode:()

ClassTest{

Privatedoublei;

PublicTest(doublei){

This.t();

This.i=i;

}

PublicTest(){

System.out.println("Defaultconstructor");

This(1);

}

Publicvoidt(){

System.out.println("Invokingt");

}

}(1分)A、this.t()maybereplacedbyt().B、this.imaybereplacedbyi.C、this(1)mustbecalledbeforeSystem.out.println("Defaultconstructor").D、this(1)mustbereplacedbythis(1.0).答案:AC解析:

暫無解析20.多選題Supposeinti=5,whichofthefollowingcanbeusedasanindexforarraydouble[]t=newdouble[100]?()(1分)A、iB、(int)(Math.random()*100))C、i+10D、i+6.5E、Math.random()*100答案:ABC解析:

暫無解析21.多選題Whichofthefollowingstatementsaretrue?()(1分)A、Aheapisacompletebinarytree.B、Eachnodeisgreaterthanorequaltoanyofitschildren.C、Abinarytreeiscompleteifeverylevelofthetreeisfullexceptthatthelastlevelmaynotbefullandalltheleavesonthelastlevelareplacedleft-most.D、Aheapisafullbinarytree.答案:ABC解析:

暫無解析22.多選題WhichofthefollowingcanbeusedtoreplaceYYYYYYYYinthefollowingcode?()

PublicclassWildCardDemo3{

Publicstaticvoidmain(String[]args){

GenericStack<String>stack1=newGenericStack<>();

GenericStack<Object>stack2=newGenericStack<>();

Stack2.push("Java");

Stack2.push(2);

Stack1.push("Sun");

Add(stack1,stack2);

WildCardDemo2.print(stack2);

}

Publicstatic<T>voidYYYYYYYY{

While(!stack1.isEmpty())

Stack2.push(stack1.pop());

}

}(1分)A、add(GenericStack<T>stack1,GenericStack<T>stack2)B、add(GenericStack<?extendsT>stack1,GenericStack<T>stack2)C、add(GenericStack<T>stack1,GenericStack<?superT>stack2)D、add(GenericStack<T>stack1,GenericStack<Object>stack2)答案:BC解析:

暫無解析23.WhichofthefollowingmethodsareintheCollectioninterface?(1分)A、add(o:E)B、addAll(c:Collection<?extendsE>)C、contains(o:Object):booleanD、containsAll(c:Collection<?>):boolean答案:ABCD解析:

暫無解析24.多選題Whichofthefollowingareincorrect?()(1分)A、Anabstractclasscontainsconstructors.B、Theconstructorsinanabstractclassshouldbeprotected.C、Theconstructorsinanabstractclassareprivate.D、Youmaydeclareafinalabstractclass.E、Aninterfacemaycontainconstructors.答案:CDE解析:

暫無解析25.多選題WhatisthepossibleoutputfromSystem.out.println((int)(Math.random()*4))?()(1分)A、0B、1C、2D、3E、4答案:ABCD解析:

暫無解析26.多選題Whatiscorrectaboutapivot?()(1分)A、Apivotdividesalistintotwosublistsofequalsize.B、Apivotcanbechosenarbitrarily.C、Apivotdividesalistintotwosublists,theelementsinthefirstlistarenolargerthanthepivotandtheelementsinthesecondlistarelargerthanthepivot.D、Youshouldalwayschooseapivotthatdividesthelistevenly.答案:BC解析:

暫無解析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解析:

暫無解析28.多選題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解析:

暫無解析29.多選題Whichofthefollowingispoordesign?()(1分)A、Adatafieldisderivedfromotherdatafieldsinthesameclass.B、Amethodmustbeinvokedafter/beforeinvokinganothermethodinthesameclass.C、Amethodisaninstancemethod,butitdoesnotreferenceanyinstancedatafieldsorinvokeinstancemethods

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論