Subclass & Setters

Based off of this Date class

Structure: … SubClass > Constructor > Super > Setter

Subclass:

IncDate is a subclass of the Date class because of the extends keyword.

Constructor:

The obligatory (?) constructor of the IncDate subclass is composed of the newMonth, newDay, newYear variable parameters.

Super:

The super keyword passes the constructor’s parameters of the subclass to the superclass. This exists because java isn’t directly able to inherit constructors.

Setter:

The setter method, also known as the Transformer method, changes the “internal” state of an object. For example, setter methods may change the variable of a object from one value to another.

Also notice that setter methods do not return a value, therefor have the void modifier in the method header.

 

 

What's Your Opinion?