Normally, you don't explicitly write the constructor for your parent class, but there are two cases where this is necessary:
Passing parameters
You want to call a parent constructor which has parameters (the default construct has no parameters). For example, if you are defining a subclass of JFrame
you might do the following.
class Chairman extends Employee {This was shown here.
. . .
//======== constructor
public Chairman(String name_,String designation_) {
super(name_);
No parameterless constructor in parent
There is no parent constructor with no parameters. Sometimes is doesn't make sense to create an object without supplying parameters.
No comments:
Post a Comment