A.CompilationfailsbecausethehashCodemethodisnotoverridden.
B.AHashSetcouldcontainmultiplePersonobjectswiththesamename.
C.AllPersonobjectswillhavethesamehashcodebecausethehashCodemethodisnotoverridden.
D.IfaHashSetcontainsmorethanonePersonobjectwithname=”Fred”,thenremovinganother person,alsowithname=”Fred”,willremovethemall.
第1题:
A.Thecodewillcompilewithoutchanges.
B.ThecodewillcompileifpublicTree(){Plant();}isaddedtotheTreeclass.
C.ThecodewillcompileifpublicPlant(){Tree();}isaddedtothePlantclass.
D.ThecodewillcompileifpublicPlant(){this(”fern”);}isaddedtothePlantclass.
E.ThecodewillcompileifpublicPlant(){Plant(”fern”);}isaddedtothePlantclass.
第2题:
给出下面不完整的类代码,则横线处的语句应该为( )。 class Person { String name,department; int age; public Person (Strings) {name=s;} public Person (String s,int
A.{name=s;age=a;} public Person (String n,String d,intA){ __________ department=d; } }A)Person (n,A);
B.this (Person(n,A));
C.this(n,A);
D.this(name,age);
第3题:
A.public Person(){}
B.public Person(String name,int age) { this.name = name; this.age = age; }
C.public Person(int age,String name) { this.age = age; this.name = name; }
D.public Person(String name) { this.name = name; }
第4题:
A.ThetimetofindthevaluefromHashMapwithaPersonkeydependsonthesizeofthemap.
B.DeletingaPersonkeyfromaHashMapwilldeleteallmapentriesforallkeysoftypePerson.
C.InsertingasecondPersonobjectintoaHashSetwillcausethefirstPersonobjecttoberemovedasaduplicate.
D.ThetimetodeterminewhetheraPersonobjectiscontainedinaHashSetisconstantanddoesNOTdependonthesizeofthemap.
第5题:
给出下列的不完整的类代码,则下列的哪个语句可以加到横线处? class Person { String name,department; int age; public Person( String n ){ name = n;} public Person( String n,int a ) { name = n;age = a;} public Person( String n,String d,int a ) { _____________ department = d; } }
A.Person(n,a);
B.this(Person(n,a) );
C.this(n,a);
D.this(name,age);