I have a segment of Java code here where an abstract class has been created. Something I'm confused on with this segment, though, is why the writer decided to use both a default constructor and a parameterized constructor.
abstract class Person {
String personName;
String personID;
//default consructor
Person() {
}
//parameterized constructor
//assigns personName and personID to object at time of creation
Person(String personName, String personID) {
this.personName = personName;
this.personID = personID;
}
//getters and setters
public String getPersonName() {
return personName;
}
public void setPersonName(String personName) {
this.personName = personName;
}
public String getPersonID() {
return personID;
}
public void setPersonID(String personID) {
this.personID = personID;
}
}
Can somebody explain why both of these constructors have been written rather than just one or the other?