Question: Here is the code for the Infant class: public class Infant{ private String name; private int age; // in months public Infant(String who, int months){
Here is the code for the Infant class:
public class Infant{ private String name; private int age; // in months public Infant(String who, int months){ name = who; age = months; } public String getName(){ return name;} public int getAge(){ return age;} public void anotherMonth(){ age = age + 1;} } The code box below includes a live Infant array variable, thoseKids. You cannot see its declaration or initialization. Your job is to find out which Infant in the array is the oldest. Write code that will determine which Infant object in the array is the oldest infant, and then prints to the console the name of that Infant. The answer you enter should execute exactly one System.out.println statement. Enter your code in the box below.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
