Design an abstract Ship class that the following members:  A field for the name of the ship (a string).  A field for the year that the ship was built (an integer).  A constructor and appropriate accessors and mutators.  A toString method that displays the ship’s name and the year it was built.

Respuesta :

Answer:

Due to error while posting the answer, the code snippet is attached as pdf file

Explanation:

The code is written in Java and it is an abstract class.

It starts by defining abstract class with the keyword "abstract".

Then it declare two field for shipName and shipYear.

Then a two arguments constructor is defined.

After that the setter and getter method is declared. The getter and setter is also known as accessor and mutator.

Then a String representation of Ship objects is done by overriding the to String method.