Why should i create empty constructor Account if already he exist because he inherit Object class?
Constructors are not inherited. If a class has no explicit constructor, hte compiler silently adds a no-argument default constructor which does nothing except call the superclass no-argument constructor. In your case, that fails for AccountStudent
because Account
does not have a no-argument constructor. Adding it is one way to resolve this. Another would be to add a constructor to AccountStudent
that calls the existing constructor of Account
, like this:
public class AccountStudent extends Account{
public AccountStudent(String owner){
super(owner);
}
}