单项选择题

A.TheequalsmethoddoesNOTproperlyoverridetheObject.equalsmethod.
B.Compilationfailsbecausetheprivateattributep.namecannotbeaccessedinline5.
C.Toworkcorrectlywithhash-baseddatastructures,thisclassmustalsoimplementthehashCodemethod.
D.WhenaddingPersonobjectstoajava.util.Setcollection,theequalsmethodinline4willpreventduplicates.
相关考题

单项选择题 publicclassPerson{privateStringname,comment;privateintage;publicPerson(Stringn,inta,Stringc){name=n;age=a;comment=c;}publicbooleanequals(Objecto){if(!(oinstanceofPerson))returnfalse;Personp=(Person)o;returnage==p.age&&name.equals(p.name);}}WhatistheappropriatedefinitionofthehashCodemethodinclassPerson?()A.returnsuper.hashCode();B.returnname.hashCode()+age*7;C.returnname.hashCode()+comment.hashCode()/2;D.returnname.hashCode()+comment.hashCode()/2-age*3;

单项选择题 Listlist=//morecodehere12.Collections.sort(list,newMyComparator());Whichcodewillsortthislistintheoppositeorderofthesortinline12?()

单项选择题 publicclassDrinkimplementsComparable{publicStringname;publicintcompareTo(Objecto){return0;}}and:Drinkone=newDrink();Drinktwo=newDrink();one.name=Coffee”;two.name=Tea”;TreeSetset=newTreeSet();set.add(one);set.add(two);AprogrammeriteratesovertheTreeSetandprintsthenameofeachDrinkobject.Whatistheresult?()A.TeaB.CoffeeC.CoffeeTeaD.Compilationfails.E.Thecoderunswithnooutput.F.Anexceptionisthrownatruntime.

单项选择题 importjava.util.*;classKeyMaster{publicinti;publicKeyMaster(inti){this.i=i;}publicbooleanequals(Objecto){returni==((KeyMaster)o).i;}publicinthashCode(){returni;}}publicclassMapIt{publicstaticvoidmain(String[]args){Setset=newHashSet();KeyMasterk1=newKeyMaster(1);KeyMasterk2=newKeyMaster(2);set.add(k1);set.add(k1);set.add(k2);set.add(k2);System.out.print(set.size()+:”);k2.i=1;System.out.print(set.size()+:”);set.remove(k1);System.out.print(set.size()+:”);set.remove(k2);System.out.print(set.size());}}Whatistheresult?()

单项选择题 通过机器手到各个网站搜集、存储信息,并建立索引数据库供用户查询的搜索引擎叫()。

单项选择题 邮件地址“gltdaozhi@buu.edu.cn”的用户名是()。

单项选择题 publicclassClassA{publicintgetValue(){intvalue=0;booleansetting=true;Stringtitle=”Hello”;(value||(setting&&title==Hello”)){return1;}(value==1&title.equals(”Hello”)){return2;}}}And:ClassAa=newClassA();a.getValue();Whatistheresult?()A.1B.2C.Compilationfails.D.Thecoderunswithnooutput.E.Anexceptionisthrownatruntime.

单项选择题 ()是指调整文本与页面边界之间的距离。

单项选择题 覆盖范围从几十千米到成百上千甚至上万千米,传输速率较低的计算机网络是()。

单项选择题 HTML是使用超文本()语言编写的。

单项选择题 单个网页框架最好不要超过()个。

单项选择题 11.classCup{}12.classPoisonCupextendsCup{}21.publicvoidtakeCup(Cupc){22.if(cinstanceofPoisonCup){23.System.out.println(”Inconceivable!”);24.}elseif(cinstanceofCup){25.System.out.println(”Dizzyingintellect!”);26.}else{27.System.exit(0);28.}29.}Andtheexecutionofthestatements:Cupcup=newPoisonCup();takeCup(cup);Whatistheoutput?()A.Inconceivable!B.Dizzyingintellect!C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.E.Compilationfailsbecauseofanerrorinline22.

单项选择题 客户刚刚提交订单,此时订单的状态是()。

单项选择题 classFoo{privateintx;publicFoo(intx){this.x=x;}publicvoidsetX(intx){this.x=x;}publicintgetX(){returnx;}}publicclassGamma{staticFoofooBar(Foofoo){foo=newFoo(100);returnfoo;}publicstaticvoidmain(String[]args){Foofoo=newFoo(300);System.out.print(foo.getX()+-);FoofooFoo=fooBar(foo);System.out.print(foo.getX()+-);System.out.print(fooFoo.getX()+-);foo=fooBar(fooFoo);System.out.print(foo.getX()+-);System.out.prmt(fooFoo.getX());}}Whatistheoutputofthisprogram?()

单项选择题 11.classPayload{12.privateintweight;13.publicPayload(intwt){weight=wt;}13.publicvoidsetWeight(mtw){weight=w;}15.publicStringtoString{returnInteger.toString(weight);}16.}17.18.publicclassTestPayload{19.staticvoidchangePayload(Payloadp){20./*insertcodehere*/21.}22.23.publicstaticvoidmain(String[]args){24.Payloadp=newPayload();25.p.setWeight(1024);26.changePayload(p);27.System.out.println(”Thevalueofpis+p);28.}29.}Whichstatement,placedatline20,causesthecodetoprintThevalueofpis420.”?()

单项选择题 publicstaticvoidtest(Stringstr){intcheck=4;if(check=str.length()){System.out.print(str.charAt(check-=1)+,);}else{System.out.print(str.charAt(0)+,);}}andtheinvocation:test(”four”);test(”tee”);test(”to”);Whatistheresult?()A.r,t,t,B.r,e,o,C.Compilationfails.D.Anexceptionisthrownatruntime.

单项选择题 Giventhefully-qualifiedclassnames:com.foo.bar.Dogcom.foo.bar.blatz.Bookcom.bar.Carcom.bar.blatz.SunWhichgraphrepresentsthecorrectdirectorystructureforaJARfilefromwhichthoseclassescanbeusedbythecompilerandJYM?()A.JarAB.JarBC.JarCD.JarDE.JarE

单项选择题 Aclassgames.cards.PokeriscorrectlydefinedinthejarfilePoker.jar.AuserwantstoexecutethemainmethodofPokeronaUNIXsystemusingthecommand:javagames.cards.PokerWhatallowstheusertodothis?()

单项选择题 publicclassScoreimplementsComparable{privateintwins,losses;publicScore(intw,int1){wins=w;losses=1;}publicintgetWins(){returnwins;}publicintgetLosses(){returnlosses;}publicStringtoString(){return<+wins+,+losses+>”;}//insertcodehere}Whichmethodwillcompletethisclass?()A.publicintcompareTo(Objecto){/*modecodehere*/}B.publicintcompareTo(Scoreother){/*morecodehere*/}C.publicintcompare(Scores1,Scores2){/*morecodehere*/}D.publicintcompare(Objecto1,Objecto2){/*morecodehere*/}

单项选择题 1.publicclassTarget{2.privateinti=0;3.publicintaddOne(){4.return++i;5.}6.}And:1.publicclassClient{2.publicstaticvoidmain(String[]args){3.System.out.println(newTarget().addOne());4.}5.}WhichchangecanyoumaketoTargetwithoutaffectingClient?()A.Line4ofclassTargetcanbechangedtoreturni++;B.Line2ofclassTargetcanbechangedtoprivateinti=1;C.Line3ofclassTargetcanbechangedtoprivateintaddOne(){D.Line2ofclassTargetcanbechangedtoprivateIntegeri=0;