Question: Interface Comparable { int compareTo(T 0) You are required to modify the Person class and implement the comparable interface. You will need to override the

 Interface Comparable { int compareTo(T 0) You are required to modify

Interface Comparable { int compareTo(T 0) You are required to modify the Person class and implement the comparable interface. You will need to override the compareTo(Person p) method. The comparison is based on the ages. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified Person. Write the modified Person class in the answer box below assuming that the student and Employee have been done for you. For example: Test Result [Employee [Susan(43), Bank tellers, 68000.00], Joe(21)] Person[] myList = new Person[2]; myList[0] = new Employee("Susan", 43, "Bank tellers", 68000); my List[1] = new Person("Joe", 21); System.out.println(Arrays.toString(myList)); [Joe (21), Employee? Susan(43), Bank tellers, 68000.00]] Person[] myList = new Person[2]; my List[0] = new Employee ("Susan", 43, "Bank tellers", 68000); myList[1] = new Person("Joe", 21); Arrays.sort(myList); System.out.println(Arrays.toString(myList)); Answer: (penalty regime: 0 %) 1 class Person implements Comparable Person> { protected string name; protected int age; public Person(String name, int age) { this.name = name; this.age = age; public int getAge() { return age; public void setAge(int age) { this.age = age; public String getName() { return name; public void setName(String name) { this.name = name; public String toString() { return String.format("%s %d)", name, age)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!