Java期末练习测试卷_第1页
Java期末练习测试卷_第2页
Java期末练习测试卷_第3页
Java期末练习测试卷_第4页
Java期末练习测试卷_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Java期末练习测试卷单选题(总共40题)1.单选题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解析:

暂无解析2.单选题FillinthemostappropriatecodeintheblanksintheMyIntclass?()

PublicclassMyIntimplements_______{

Intid;

PublicMyInt(intid){

This.id=id;

}

PublicStringtoString(){

ReturnString.valueOf(id);

}

PublicintcompareTo(_______arg0){

If(id>arg0.id)

Return1;

Elseif(id<arg0.id)

Return-1;

Else

Return0;

}

}(1分)A、Comparable/ObjectB、Comparable<MyInt>/MyIntC、Comparable<MyInt>/ObjectD、Comparable/MyInt答案:B解析:

暂无解析3.TodeclareaninterfacenamedAwithagenerictype,use(1分)A、publicinterfaceA<E>{...}B、publicinterfaceA<E,F>{...}C、publicinterfaceA(E){...}D、publicinterfaceA(E,F){...}答案:A解析:

暂无解析4.单选题Analyzethefollowingcode.()

ClassTest{

Publicstaticvoidmain(String[]args){

StringBuilderstrBuf=newStringBuilder(4);

StrBuf.append("ABCDE");

System.out.println("What'sstrBuf.charAt(5)?"+strBuf.charAt(5));

}

}(1分)A、TheprogramhasacompileerrorbecauseyoucannotspecifyinitialcapacityintheStringBuilderconstructor.B、Theprogramhasaruntimeerrorbecausebecausethebuffer'scapacityis4,butfivecharacters"ABCDE"areappendedintothebuffer.C、Theprogramhasaruntimeerrorbecausethelengthofthestringinthebufferis5after"ABCDE"isappendedintothebuffer.Therefore,strBuf.charAt(5)isoutofrange.)D、Theprogramcompilesandrunsfine.)答案:C解析:

暂无解析5.单选题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解析:

暂无解析6.单选题Supposeaheapisstoredinanarraylistasfollows:{100,55,92,23,33,81}.Afterinserting103,whatisthecontentofthearraylist?()(1分)A、{100,55,92,23,33,81,103}B、{100,55,103,23,33,92,81}C、{103,55,92,23,33,81,92}D、{103,55,100,23,33,81,92}E、{103,55,92,23,33,81,100}答案:D解析:

暂无解析7.单选题Whichofthefollowingstatementsisfalse?()(1分)A、Apublicclasscanbeaccessedbyaclassfromadifferentpackage.B、Aprivatemethodcannotbeaccessedbyaclassinadifferentpackage.C、Aprotectedmethodcanbeaccessedbyasubclassinadifferentpackage.D、Amethodwithnovisibilitymodifiercanbeaccessedbyaclassinadifferentpackage.答案:D解析:

暂无解析8.单选题Whatmodifiershouldyouuseonaclasssothataclassinthesamepackagecanaccessitbutaclass(includingasubclass)inadifferentpackagecannotaccessit?()(1分)A、publicB、privateC、protectedD、Usethedefaultmodifier.答案:D解析:

暂无解析9.单选题TheGrahamalgorithmforfindingaconvexhulltakes______________time.()(1分)A、O(n)B、O(nlogn)C、O(logn)D、O(n^2)答案:B解析:

暂无解析10.单选题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解析:

暂无解析11.单选题FillinthecodeinComparable______c=newDate();()(1分)A、<String>B、<?>C、<Date>D、<E>答案:C解析:

暂无解析12.单选题Showtheoutputofthefollowingcode()

PublicclassTest1{

Publicstaticvoidmain(String[]args){

System.out.println(f2(2,0));

}

Publicstaticintf2(intn,intresult){

If(n==0)

Return0;

Else

Returnf2(n-1,n+result);

}

}(1分)A、0B、1C、2D、3答案:A解析:

暂无解析13.单选题Ifyouwanttostorenon-duplicatedobjectsintheorderinwhichtheyareinserted,youshoulduse____________.()(1分)A、HashSetB、LinkedHashSetC、TreeSetD、ArrayListE、LinkedList答案:B解析:

暂无解析14.单选题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解析:

暂无解析15.单选题Theoutputofthefollowingcodeis____________.()

LinkedHashSet<String>set1=newLinkedHashSet<>();

Set1.add("NewYork");

LinkedHashSet<String>set2=(LinkedHashSet<String>)(set1.clone());

Set1.add("Atlanta");

Set2.add("Dallas");

System.out.println(set2);(1分)A、[NewYork]B、[NewYork,Atlanta]C、[NewYork,Atlanta,Dallas]D、[NewYork,Dallas]答案:D解析:

暂无解析16.单选题Whatistheoutputofthefollowingcode?()

Importjava.util.*;

PublicclassTest{

Publicstaticvoidmain(String[]args){

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

List.add(newStudent("Peter",65));

List.add(newStudent("Jill",50));

List.add(newStudent("Sarah",34));

Collections.sort(list);

System.out.print(list+"");

Collections.sort(list,newStudentComparator1());

System.out.println(list);

}

StaticclassStudentComparator1implementsComparator<Student>{

Publicintcompare(Students1,Students2){

ReturnpareTo();

}

}

StaticclassStudentimplementsComparable<Student>{

Stringname;

Intage;

Student(Stringname,intage){

T=name;

This.age=age;

}

PublicintcompareTo(Students){

Returnthis.age-s.age;

}

PublicStringtoString(){

Return"["+name+","+age+"]";

}

}

}(1分)A、[[Sarah,34],[Jill,50],[Peter,65]][[Sarah,34],[Jill,50],[Peter,65]]B、[[Jill,50],[Peter,65],[Sarah,34]][[Jill,50],[Peter,65],[Sarah,34]]C、[[Sarah,34],[Jill,50],[Peter,65]][[Jill,50],[Peter,65],[Sarah,34]]D、[[Jill,50],[Peter,65],[Sarah,34]][[Sarah,34],[Jill,50],[Peter,65]]答案:C解析:

暂无解析17.单选题Whatistheoutputofthefollowingcode?()

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

List.add(1);

List.add(2);

List.add(3);

List.remove(2);

System.out.println(list);(1分)A、[1,2,3]B、[1,2]C、[1]D、[1,3]E、[2,3]答案:B解析:

暂无解析18.单选题Whichdatatypeshouldyouuseifyouwanttostoreduplicateelementsandbeabletoinsertordeleteelementsanywhereefficiently?()(1分)A、ArrayListB、LinkedListC、VectorD、SetE、Stack答案:B解析:

暂无解析19.单选题Whatisdisplayedbythefollowingstatement?()

System.out.println("Javaisneat".replaceAll("is","AAA"));(1分)A、JavaAAAneatB、JavaAAAneatC、JavaAAAneatD、JavaAAAneat答案:C解析:

暂无解析20.单选题Showtheoutputofthefollowingcode:()

PublicclassTest{

Publicstaticvoidmain(String[]args){

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

Increase(x);

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

Increase(y[0]);

System.out.println(x[0]+""+y[0]);

}

Publicstaticvoidincrease(int[]x){

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

X[i]++;

}

Publicstaticvoidincrease(inty){

Y++;

}

}(1分)A、00B、11C、22D、21E、12答案:D解析:

暂无解析21.单选题Analyzethefollowingcode.()

1publicclassTest{

2publicstaticvoidmain(String[]args){

3Fruit[]fruits={newFruit(2),newFruit(3),newFruit(1)};

4java.util.Arrays.sort(fruits);

5}

6}

ClassFruit{

Privatedoubleweight;

PublicFruit(doubleweight){

This.weight=weight;

}

}(1分)A、TheprogramhasacompileerrorbecausetheFruitclassdoesnothaveano-argconstructor.B、TheprogramhasaruntimeerroronLine3becausetheFruitclassdoesnothaveano-argconstructor.C、TheprogramhasacompileerroronLine4becausetheFruitclassdoesnotimplementthejava.lang.ComparableinterfaceandtheFruitobjectsarenotcomparable.D、TheprogramhasaruntimeerroronLine4becausetheFruitclassdoesnotimplementthejava.lang.ComparableinterfaceandtheFruitobjectsarenotcomparable.答案:D解析:

暂无解析22.单选题WhatistheoutputofrunningclassTest?()

PublicclassTest{

Publicstaticvoidmain(String[]args){

NewCircle9();

}

}

PublicabstractclassGeometricObject{

ProtectedGeometricObject(){

System.out.print("A");

}

ProtectedGeometricObject(Stringcolor,booleanfilled){

System.out.print("B");

}

}

PublicclassCircle9extendsGeometricObject{

/**No-argconstructor*/

PublicCircle9(){

This(1.0);

System.out.print("C");

}

/**Constructcirclewithaspecifiedradius*/

PublicCircle9(doubleradius){

This(radius,"white",false);

System.out.print("D");

}

/**Constructacirclewithspecifiedradius,filled,andcolor*/

PublicCircle9(doubleradius,Stringcolor,booleanfilled){

Super(color,filled);

System.out.print("E");

}

}(1分)A、ABCDB、BACDC、CBAED、AEDCE、BEDC答案:E解析:

暂无解析23.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解析:

暂无解析24.单选题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解析:

暂无解析25.单选题Supposeyouwishtoprovideanaccessormethodforabooleanpropertyfinished,whatsignatureofthemethodshouldbe?()(1分)A、publicvoidgetFinished()B、publicbooleangetFinished()C、publicbooleanisFinished()D、publicvoidisFinished()答案:C解析:

暂无解析26.单选题Tofindamaximumobjectinanarrayofstrings()g点,String[]names={"red","green","blue"}),use(D)(1分)A、Arrays.max(names)B、Arrays.sort(names)C、Collections.max(names)D、Collections.max(Arrays.asList(names))E、Noneoftheabove答案:E解析:

暂无解析27.单选题ThetimecomplexityfortheTowersofHonoialgorithminthetextis________.()(1分)A、O(n)B、O(n^2)C、O(n^3)D、O(2^n)答案:D解析:

暂无解析28.单选题WhichofthefollowingdatatypesdoesnotimplementtheCollectioninterface?()(1分)A、HashSetB、TreeSetC、ArrayListD、LinkedListE、Map答案:E解析:

暂无解析29.单选题Giventworeferencevariablest1andt2,ift1.equals(t2)istrue,t1==t2___________.()(1分)A、isalwaystrueB、isalwaysfalseC、maybetrueorfalse答案:C解析:

暂无解析30.单选题Analyzethefollowingcode.()

//Program1:

PublicclassTest{

Publicstaticvoidmain(String[]args){

Objecta1=newA();

Objecta2=newA();

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

}

}

ClassA{

Intx;

Publicbooleanequals(Objecta){

Returnthis.x==((A)a).x;

}

}

//Program2:

PublicclassTest{

Publicstaticvoidmain(String[]args){

Objecta1=newA();

Objecta2=newA();

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

}

}

ClassA{

Intx;

Publicbooleanequals(Aa){

Returnthis.x==a点x;

}

}(1分)A、Program1displaystrueandProgram2displaystrueB、Program1displaysfalseandProgram2displaystrueC、Program1displaystrueandProgram2displaysfalseD、Program1displaysfalseandProgram2displaysfalse答案:C解析:

暂无解析31.单选题WhatisthereturnvalueforxMethod(4)aftercallingthefollowingmethod?()

StaticintxMethod(intn){

If(n==1)

Return1;

Else

Returnn+xMethod(n-1);

}(1分)A、12B、11C、10D、9答案:C解析:

暂无解析32.单选题Fillinthecodetocompletethefollowingmethodforcheckingwhetherastringisapalindrome.()

PublicstaticbooleanisPalindrome(Strings){

ReturnisPalindrome(s,0,s.length()-1);

}

PublicstaticbooleanisPalindrome(Strings,intlow,inthigh){

If(high<=low)//Basecase

Returntrue;

Elseif(s.charAt(low)!=s.charAt(high))//Basecase

Returnfalse;

Else

Return_______________________________;

}(1分)A、isPalindrome(s)B、isPalindrome(s,low,high)C、isPalindrome(s,low+1,high)D、isPalindrome(s,low,high-1)E、isPalindrome(s,low+1,high-1)答案:E解析:

暂无解析33.单选题FillinthecodeinComparable______c=newDate();()(1分)A、<String>B、<?>C、<Date>D、<E>答案:A解析:

暂无解析34.单选题Theiterator()methodisdefinedinthe__________interface.()(1分)A、IteratorB、CollectionC、IterableD、ArrayList答案:C解析:

暂无解析35.单选题_______isnotareferencetype.()(1分)A、AclasstypeB、AninterfacetypeC、AnarraytypeD、Aprimitivetype答案:D解析:

暂无解析36.单选题FillinthemostappropriatecodeintheblanksintheMyIntclass?()

PublicclassMyIntimplements_______{

Intid;

PublicMyInt(intid){

This.id=id;

}

PublicStringtoString(){

ReturnString.valueOf(id);

}

PublicintcompareTo(_______arg0){

If(id>arg0.id)

Return1;

Elseif(id<arg0.id)

Return-1;

Else

Return0;

}

}(1分)A、Comparable/ObjectB、Comparable<MyInt>/MyIntC、Comparable<MyInt>/ObjectD、Comparable/MyInt答案:B解析:

暂无解析37.单选题GiventhedeclarationCirclex=newCircle(),whichofthefollowingstatementismostaccurate.()(1分)A、xcontainsanintvalue.B、xcontainsanobjectoftheCircletype.C、xcontainsareferencetoaCircleobject.D、Youcanassignanintvaluetox.答案:C解析:

暂无解析38.单选题ThetimecomplexityfortheEuclidalgorithmis________.()(1分)A、O(n)B、O(n^2)C、O(logn)D、O(2^n)答案:C解析:

暂无解析39.单选题Whatarethebasecasesinthefollowingrecursivemethod?()

PublicstaticvoidxMethod(intn){

If(n>0){

System.out.print(n%10);

XMethod(n/10);

}

}(1分)A、n>0B、n<=0C、nobasecasesD、n<0答案:B解析:

暂无解析40.单选题Usingthepartitionalgorithmtopartitionanarray{5,8,10,3,4,19,2}foraquicksort,whatistheresultingarrayafterthepartition?()(1分)A、{5,8,10,3,4,19,2}B、{2,3,4,5,8,10,19}C、{2,3,4,5,10,19,8}D、{3,2,4,5,10,19,8}E、{3,2,4,5,8,10,19}答案:D解析:

暂无解析多选题(总共40题)1.多选题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解析:

暂无解析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.多选题__________returnsastring.()(1分)A、String.valueOf(123)B、String.valueOf(12.53)C、String.valueOf(false)D、String.valueOf(newchar[]{'a','b','c'})答案:ABCD解析:

暂无解析4.多选题Whatiscorrectaboutapivot?()(1分)A、Apivotdividesalistintotwosublistsofequalsize.B、Apivotcanbechosenarbitrarily.C、Apivotdividesalistintotwosublists,theelementsinthefirstlistarenolargerthanthepivotandtheelementsinthesecondlistarelargerthanthepivot.D、Youshouldalwayschooseapivotthatdividesthelistevenly.答案:BC解析:

暂无解析5.多选题WhichofthefollowingarecorrectmethodsinMap?()(1分)A、containsKey(Objectkey)B、containsValue(Objectvalue)C、remove(Objectkey)D、remove(intindex)E、isEmpty()答案:ABCE解析:

暂无解析6.多选题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解析:

暂无解析7.多选题Whichofthefollowingstatementsaretrue?()(1分)A、TheStringclassimplementsComparable.B、TheDateclassimplementsComparable.C、TheDoubleclassimplementsComparable.D、TheBigIntegerclassimplementsComparable.答案:ABCD解析:

暂无解析8.多选题Whichofthefollowingstatementsistrue?()(1分)A、Youcanalwayspassaninstanceofasubclasstoaparameterofitssuperclasstype.Thisfeatureisknownaspolymorphism.B、Thecompilerfindsamatchingmethodaccordingtoparametertype,numberofparameters,andorderoftheparametersatcompiletime.C、Amethodmaybeimplementedinseveralsubclasses.TheJavaVirtualMachinedynamicallybindstheimplementationofthemethodatruntime.D、Dynamicbindingcanapplytostaticmethods.E、Dynamicbindingcanapplytoinstancemethods.答案:ABCE解析:

暂无解析9.多选题Whichofthefollowingstatementsaretrue?()(1分)A、Aclassshoulddescribeasingleentityandalltheclassoperationsshouldlogicallyfittogethertosupportacoherentpurpose.B、Aclassshouldalwayscontainano-argconstructor.C、Theconstructorsmustalwaysbepublic.D、Theconstructorsmaybeprotected.答案:AD解析:

暂无解析10.多选题Analyzethefollowingcode:()

PublicclassTestextendsA{

Publicstaticvoidmain(String[]args){

Testt=newTest();

T.print();

}

}

ClassA{

Strings;

A(Strings){

This.s=s;

}

Publicvoidprint(){

System.out.println(s);

}

}(1分)A、TheprogramdoesnotcompilebecauseTestdoesnothaveadefaultconstructorTest().B、TheprogramhasanimplicitdefaultconstructorTest(),butitcannotbecompiled,becauseitssuperclassdoesnothaveadefaultconstructor.TheprogramwouldcompileiftheconstructorintheclassAwereremoved.C、TheprogramwouldcompileifadefaultconstructorA(){}isaddedtoclassAexplicitly.D、Theprogramcompiles,butithasaruntimeerrorduetotheconflictonthemethodnameprint.答案:BC解析:

暂无解析11.多选题Whichofthefollowingstatementsarecorrect?()(1分)A、WhencreatingaRandomobject,youhavetospecifytheseedorusethedefaultseed.B、IftwoRandomobjectshavethesameseed,thesequenceoftherandomnumbersobtainedfromthesetwoobjectsareidentical.C、ThenextInt()methodintheRandomclassreturnsthenextrandomintvalue.D、ThenextDouble()methodintheRandomclassreturnsthenextrandomdoublevalue.答案:ABCD解析:

暂无解析12.多选题Whichofthefollowingstatementsaretrue?()(1分)A、Everyrecursivemethodmusthaveabasecaseorastoppingcondition.B、Everyrecursivecallreducestheoriginalproblem,bringingitincreasinglyclosertoabasecaseuntilitbecomesthatcase.C、Infiniterecursioncanoccurifrecursiondoesnotreducetheprobleminamannerthatallowsittoeventuallyconvergeintothebasecase.D、Everyrecursivemethodmusthaveareturnvalue.E、Arecursivemethodisinvokeddifferentlyfromanon-recursivemethod.答案:ABC解析:

暂无解析13.多选题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解析:

暂无解析14.多选题Theelementsin________aresorted.()(1分)A、TreeSetB、ListC、TreeMapD、HashSetE、LinkedHashSet答案:AC解析:

暂无解析15.多选题TheRationalclassinthischapterisdefinedasasubclassofjava.lang.Number.Whichofthefollowingexpressionsiscorrect?()(1分)A、Rational.doubleValue();B、Rational.doubleValue("5/4");C、newRational(5,4).doubleValue();D、newRational(5,4).toDoubleValue();E、newRational(5,4).intValue();答案:CE解析:

暂无解析16.多选题SupposeArrayListxcontainstwostrings[Beijing,Singapore].Whichofthefollowingmethodwillcauseruntimeerrors?()(1分)A、x.get(1)B、x.set(2,"NewYork");C、x.get(2)D、x.remove(2)E、x.size()答案:BCD解析:

暂无解析17.多选题WhichofthefollowingcomplexityisO(nlogn)?()(1分)A、300n+400n*nB、23nlogn+50C、45n+45nlogn+503D、n*n*n+nlogn答案:BC解析:

暂无解析18.多选题Whichofthefollowingstatementsiscorrect?()(1分)A、Genericscanhelpdetecttypeerrorsatcompiletime,thusmakeprogramsmorerobust.B、Genericscanmakeprogramseasytoread.C、Genericscanavoidcumbersomecastings.D、Genericscanmakeprogramsrunfaster.答案:ABC解析:

暂无解析19.多选题Whichofthefollowingstatementsarecorrect?()(1分)A、newJava.math.BigInteger("343");B、newjava.math.BigDecimal("343.445");C、newjava.math.BigInteger(343);D、newjava.math.BigDecimal(343.445);答案:AB解析:

暂无解析20.多选题Whichofthefollowingstatementsconvertadoublevaluedintoastrings?()(1分)A、s=(newDouble(d)).toString();B、s=d;C、s=newDouble(d).stringOf();D、s=String.stringOf(d);E、s=d+"";答案:AE解析:

暂无解析21.多选题Whichofthefollowingaretrue?()(1分)A、Youcaninsertanelementanywhereinanarraylist.B、Youcaninsertanelementanywhereinalinkedlist.C、Youcanusealinkedlisttoimproveefficiencyforaddingandremovingelementsatthebeginningofalist.D、Youshoulduseanarraylistifyourapplicationdoesnotrequireaddingandremovingelementsatthebeginningofalist.答案:ABCD解析:

暂无解析22.多选题SupposeAisanabstractclass,Bisaconcretesubclassof

A,andbothAandBhaveano-argconstructor.Whichofthefollowingiscorrect?()(1分)A、Aa=newA();B、Aa=newB();C、Bb=newA();D、Bb=newB();答案:BD解析:

暂无解析23.多选题Assumesis"ABCABC",themethod__________returnsanewstring"aBCaBC".()(1分)A、s.toLowerCase(s)B、s.toLowerCase()C、s.replace('A','a')D、s.replace('a','A')E、s.replace("ABCABC","aBCaBC")答案:CE解析:

暂无解析24.多选题Whichofthefollowingstatementsaretrue?()(1分)A、AnArrayListcangrowautomatically.B、AnArrayListcanshrinkautomatically.C、YoucanreducethecapacityofanArrayListbyinvokingthetrimToSize()methodonthelist.D、YoucanreducethecapacityofaLinkedListbyinvokingthetrimToSize()methodonthelist.答案:AC解析:

暂无解析25.多选题SupposeArrayListxcontainsthreestrings[Beijing,Singapore,Tokyo].Whichofthefollowingmethodswillcauseruntimeerrors?()(1分)A、x.get(2)B、x.set(3,"NewYork");C、x.get(3)D、x.remove(3)E、x.size()答案:BCD解析:

暂无解析26.多选题Whichofthefollowingarevalidspecifiersfortheprintfstatement?()(1分)A、%4cB、%10bC、%6dD、%8.2dE、%10.2e答案:ABCE解析:

暂无解析27.多选题Whichofthefollowingstatementsaretrue?()(1分)A、Multipleconstructorscanbedefinedinaclass.B、Constructorsdonothaveareturntype,notevenvoid.C、Constructorsmusthavethesamenameastheclassitself.D、Constructorsareinvokedusingthenewoperatorwhenanobjectiscreated.答案:ABCD解析:

暂无解析28.多选题Whichofthefollowingstatementsaretrue?(1分)A、TheComparableinterfacecontainsthecompareTomethodwiththesignature"publicintcompareTo(E)".B、TheComparatorinterfacecontainsthecomparemethodwiththesignature"publicintcompare(

E,E)".C、AComparableobjectcancomparethisobjectwiththeotherobject.D、AComparatorobjectcontainsthecomparemethodthatcomparestwoobjects.答案:ABCD解析:

暂无解析29.多选题Whyistheanalysisoftenfortheworstcase?()(1分)A、Best-caseisnotrepresentative.B、Worst-caseisnotrepresentative,butworst-caseanalysisisveryuseful.Youcanshowthatthealgorithmwillneverbeslowerthantheworst-case.C、Average-caseanalysisisideal,butdifficulttoperform,becauseitishardtodeterminetherelativeprobabilitiesanddistributionsofvariousinputinstancesformanyproblems.答案:ABC解析:

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

暂无解析31.多选题Whichofthefollowingstatementsaretrue?()(1分)A、Asubclassisasubsetofasuperclass.B、Asubclassisusuallyextendedtocontainmorefunctionsandmoredetailedinformationthanitssuperclass.C、"classAextendsB"meansAisasubclassofBD、"classAextendsB"meansBisasubclassofA答案:BC解析:

暂无解析32.多选题Whichofthefollowingstatementsarecorrect?()(1分)A、Whenyoucreateanarrayusingnewint[10],anarrayobjectiscreatedwithtenintegersofvalue0.B、Whenyoucreateanarrayusingnewint[10],anarrayobjectiscreatedwithnovaluesinthearray.C、WhenyoucreateanArrayListusingnewArrayList(),anArrayListobjectiscreatedwithnoelementsintheArrayListobject.D、Whenyoucreateanarrayusingint[]x=newint[10],x.length()is10.E、WhenyoucreateanarrayusingArrayListx=newArrayList(10),x.size()is10.答案:ACD解析:

暂无解析33.多选题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()methodandmakei

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论