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

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

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!