Question
In JAVA Develop a class definition for a Person. Then develop a class definition for a Military Person that inherits the properties of the Person,
In JAVA
Develop a class definition for a Person. Then develop a class definition for a Military Person that
inherits the properties of the Person, and a Navy Sailor that inherits the properties of a Military
Person. Finally, create two classes; an Officer and an Enlisted that each can inherit the properties of
a Navy Sailor. At each level, include the following class variables:
Person: FirstName, MiddleInitial, LastName, Gender
*
Military Person: Active Duty or Reserve
*
Navy Sailor: Base where stationed, Surface Ship or Submarine, Date Commissioned, Rank
Include a toString() method in each class that will print out what type of class it is. Include methods
read each of the class variables (i.e., getRank()) and methods to change the value of each class
variable. Finally, develop methods so that all of the information in an object can be printed out.
Write a short main() program to test it out.
Important Note: Be sure to incorporate the principles of encapsulation (Chapter 8) in your
definitions.
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