日期:2014-05-20  浏览次数:20620 次

帮忙做道题目,顺便解释下..谢谢..
public   class   Person{
        private   String   name;
        public   Person(String   name){this.name   =   name;}
        public   boolean   equals(Person   p){
                return   p.name.equals(this.name);
        }
}

Which   statement   is   true?
A.   The   equals   method   does   NOT   properly   override   the   Object.equals   method.
B.   Compilation   fails   because   the   private   attribute   p.name   cannot   be   accessed   in   line   5.
C.   To   work   correctly   with   hash-based   data   structures,   this   class   must   also   implement   the
hashCode   method.
D.   When   adding   Person   objects   to   java.util.   Set   collection,   the   equals   method   in   line   4   will   prevent   duplicates.




------解决方案--------------------
自己拿来试撒
------解决方案--------------------
答案是A