As I was progressing through my java course, I came across this exercise where I create a commissionemployee class.
public class CommissionEmployee extends Object{ //This is not required, because every class extends Object by default, and the toString method in Object is returned when printing an object.
private final String firstname;
private final String lastname;
private final String socialSecurityNumber;
private double grossSales;
private double commissionRate;
public CommissionEmployee(String firstname, String lastname, String socialSecurityNumber, double grossSales, double commissionRate){ //constructor starts here
And all the methods defined inside this class are only getFirstname(), getLastname, etc. and no set methods to alter already initialized object, and an object can be created only by passing all the variables as parameters, because there is no default constructor.
In this scenario, why was the instance variables declared as private final String
? Why was private String
not preferred by my course instructor? and why was grossSales
and commissionRate
not declared as final
?