题目内容 (请给出正确答案)
[主观题]

publicclassPerson{privatename;publicPerson(Stringname){this.name=name;}publicbooleanequals(Objecto){if(!oinstanceofPerson)returnfalse;Personp=(Person)o;returnp.name.equals(this.name);}}Whichistrue?()

A.CompilationfailsbecausethehashCodemethodisnotoverridden.

B.AHashSetcouldcontainmultiplePersonobjectswiththesamename.

C.AllPersonobjectswillhavethesamehashcodebecausethehashCodemethodisnotoverridden.

D.IfaHashSetcontainsmorethanonePersonobjectwithname=”Fred”,thenremovinganother person,alsowithname=”Fred”,willremovethemall.

查看答案
如搜索结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能会需要:
您的账号:
发送账号密码至手机
发送
更多“publicclassPerson{privatename;…”相关的问题

第1题

Giventhefollowingcode:publicclassPerson{staticintarr[]=newint[10];publicstaticvoidmain(Stringa[]){System.out.println(arr[1];)}}Whichstatementiscorrect?()

A.Whencompilationsomeerrorwilloccur.

B.Itiscorrectwhencompilationbutwillcauseerrorwhenrunning.

C.Theoutputiszero.

D.Theoutputisnull.

点击查看答案

第2题

publicclassPerson{privatename;publicPerson(Stringname){this.name=name;}publicinthashCode(){return420;}}Whichistrue?()

A.ThetimetofindthevaluefromHashMapwithaPersonkeydependsonthesizeofthemap.

B.DeletingaPersonkeyfromaHashMapwilldeleteallmapentriesforallkeysoftypePerson.

C.InsertingasecondPersonobjectintoaHashSetwillcausethefirstPersonobjecttoberemovedasaduplicate.

D.ThetimetodeterminewhetheraPersonobjectiscontainedinaHashSetisconstantanddoesNOTdependonthesizeofthemap.

点击查看答案

第3题

阅读下列代码publicclassPerson{staticintalt[]=newint[[10];public static voidmain(Stringargs

阅读下列代码 publicclassPerson{ staticintalt[]=newint[[10]; public static voidmain(Stringargs){ System.out.println{all[9]); } } 该代码的运行结果是()。

A.编译时将产生错误

B.编译时正确,运行时将产生错误

C.输出零

D.输出空

点击查看答案

第4题

publicclassPerson{2.privateStringname;3.publicPerson(Stringname){this.name=name;}4.publicbooleanequals(Personp){5.returnp.name.equals(this.name);6.}7.}Whichistrue?()

A.TheequalsmethoddoesNOTproperlyoverridetheObject.equalsmethod.

B.Compilationfailsbecausetheprivateattributep.namecannotbeaccessedinline5.

C.Toworkcorrectlywithhash-baseddatastructures,thisclassmustalsoimplementthehashCodemethod.

D.WhenaddingPersonobjectstoajava.util.Setcollection,theequalsmethodinline4willpreventduplicates.

点击查看答案

第5题

以下代码执行后的结果是:()。publicclassPerson{undefinedStringname=“小芳”;publicPerson(Stringname){undefinedname=“小兰”;}publicvoidshow(){undefinedthis.name=“小翠”;}publicstaticvoidmain(String[]args){undefinedPersonp=newPerson(“小凤”);System.out.print(p.name);p.show();System.out.print(p.name);}}

A.小兰小翠

B.小凤小翠

C.小芳小翠

D.程序编码失败

点击查看答案

第6题

Giventhefollowingcode:publicclassPerson{intarr[]=newint[10];publicstaticvoidmain(Stringa[]){System.out.println(arr[1]);}}Whichstatementiscorrect?()

A.Whencompilationsomeerrorwilloccur.

B.Itiscorrectwhencompilationbutwillcauseerrorwhenrunning.

C.Theoutputiszero.

D.Theoutputisnull.

点击查看答案

第7题

下列选项中,哪一个类是Object的子类?()

A.publicfinalclassString{}

B.publicclassPerson{}

C.publicabstractAnimal{}

D.以上三个类都是Object子类

点击查看答案

第8题

publicclassPerson{privateStringname,comment;privateintage;publicPerson(Stringn,inta,String
c){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;

点击查看答案

第9题

Whichthreedemonstratean“isa”relationship?()

A.publicclassX{ } publicclassYextendsX{}

B.publicinterfaceShape{} publicinterfaceRectangleextendsShape{}

C.publicinterfaceColor{} publicclassShape{privateColorcolor;}

D.publicinterfaceSpecies{} publicclassAnimal{privateSpeciesspecies;}

E.publicclassPerson{}publicclassEmployee{ publicEmployee(Personperson){}

F.interfaceComponent{} classContainerimplementsComponent{privateComponent[]children;}

点击查看答案

第10题

以下代码执行后的结果是:()。publicclassPerson{undefinedStringname=“小芳”;publicPerson(Stringname){undefinedname=“小兰”;}publicvoidshow(){undefinedthis.name=“小翠”;}publicstaticvoidmain(String[]args){undefinedPersonp=newPerson(“小凤”);System.out.print(p.name);p.show();System.out.print(p.name);}}

A.小兰小翠

B.小凤小翠

C.小芳小翠

D.程序编译失败

点击查看答案
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
温馨提示
每个试题只能免费做一次,如需多次做题,请购买搜题卡
立即购买
稍后再说
警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
赏学吧
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反赏学吧购买须知被冻结。您可在“赏学吧”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
赏学吧
点击打开微信