Олимпиадный тренинг

Задача . 22


Задача

Темы:
 public class Name
    {
        private String firstName;
        private String lastName;
        public Name(String first, String last) //constructor
        {
            firstName = first;
            lastName = last;
        }
        public String toString()
        { return firstName + " " + lastName; }
        public boolean equals(Object obj)
        {
            Name n = (Name)obj;
            return n.firstName.equals(firstName) &&
            n.lastName.equals(lastName);
        }
        public int hashCode()
        { /* implementation not shown */ }
        public int compareTo(Name n)
        {
            /* more code */
        }
    }

Which statement about the Name class is false?
(A) Name objects are immutable.
(B) It is possible for the methods in Name to throw a NullReferenceException.
(C) If n1 and n2 are Name objects in a client class, then the expressions n1.equals(n2) and n1.compareTo(n2) == 0 must have the same value.
(D) The compareTo method throws a run-time exception if the parameter is null.
(E) Since the Name class has a compareTo method, it must provide an implementation for an equals method.

time 1000 ms
memory 32 Mb
Правила оформления программ и список ошибок при автоматической проверке задач

Статистика успешных решений по компиляторам
Комментарий учителя