Question: . What five objects are created in the main? Can you spot the Comparator constructor call? Where is the class definition for the Comparator? 4


. What five objects are created in the main? Can you spot the Comparator constructor call? Where is the class definition for the Comparator? 4 MyCompare3.java X Dog.java 1 import java.util.*; 2 3 class Animal { String name; 5 int legs; 6 70 Animal(String name, int legs) { 8 this.name = name; 9 this.legs = legs; 10 } 11 120 public int getLegs() { 13 return this. legs; 14 } 15 160 public String getName() { 17 return this.name; 18 } 19} 20 21 class Dog extends Animal{ 22 public Dog (String name, int legs) { 23 super(name, legs); 24 } 25 260 @Override A27 public String toString() { 28 String s = this.getName() + " has " + this.getLegs() + " legs"; 29 return s; 30 } 31 } 32 33 class MyClass { // Demo 340 public static void main(String... args) { 35 List
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
