Question: 2) Write a class Person that has 3 variables (use appropriate access modifiers): a string name, an integer age and a character gender that takes
2) Write a class Person that has 3 variables (use appropriate access modifiers): a string name, an integer age and a character gender that takes either M (for Mae) or F(for Female). Define a constructor for this class that takes a string, an integer and a character and set the three variables to the passed parameters. Also write a method called showDetails that prints the details of the person calling this method. Implement necessary set and get methods. Implement the method toString() that returns a string value of the persons information. Implement a method called compareTo that takes an object as input and returns the value of string comparison of the names of two persons
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
