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;
第1题:
阅读下面代码 abstract class Person { public Person(String n) { name=n; } public______String getDescription(); public String getName() { return name; } private String name; } 在下画线处应填入的修饰符是
A.static
B.abstract
C.protected
D.final
第2题:
给出下列的不完整的类代码,则下列的哪个语句可以加到横线处? 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);
第3题:
为使下列代码正常运行,应该在下划线【 】处填入的选项是 abstract class Person{ private String name; public Person(String n){ name=n; } public 【 】 String getDescription(); public String getName(){ return name; } }
A.static
B.private
C.abstract
D.final
第4题:
为使下列代码正常运行,应该在下画线处填入的选项是( )。 abstract class person{ public Person(String n){ name=n: } Public String getDescription; public String getName{ return name; } private string name; }
A.static
B.private
C.abstract
D.final
第5题:
为使下列代码正常运行,应该在下划线处填入的选项是()abstract class Person { private String name; public Person (String n) { name = n; } public ____________String get Description(); public String getName() { return name; } }
A.private
B.abstract
C.final
D.static