Question
Question 3: In this question, you must write part of a main method to solve a problem using two classes that you can assume are
Question 3:
In this question, you must write part of a "main" method to solve a problem using two classes that you can assume are provided already.
Here are the classes that are provided. The contents of the methods are omitted, because you don't need to know how they work.
class Person {
public int howManyChildren() { ... }
// returns an integer that is the number of children the Person has
public String getName() { ... }
// returns the name of the Person
}
class PersonReader {
public PersonReader() { ... }
// a constructor - creates its own Reader object, and whatever else it needs
public Person readPerson() { ... }
// reads enough input data to make an object of the class Person, and returns that object. (This is like
// Formats readLine( ) method, which reads and returns a String.
}
Complete the program below. It is intended to read the data about 20 people, storing each in an object of type Person. Then it prints the name of the Person(s) with the largest number of children. Your code should handle case where two or more parents have the same number of children (that could be highest).
public class WhoHasTheMostChildren {
public static void main (String[] args) {
.....
}
}
Question 4;
1)Write an example to demonstrate overriding of static methods?
2)How is dynamic binding useful in enabling a small executable size in Java? Explain.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started