CodesJava

Easy learning with example program codes

why an interface cannot have constructor in java?


Because interface not have any instance fields so nothing to construct. Now the question arise how interface can be inherited without constructor because subclass constructor call super class constructor. Now we have two cases. First case is when an interface extends other interface, in this case there is no issue because no interface have constructor and hence no super class constructor call. Second case when a class implements an interface, in this case there is no inheritance because class implements interface not extends interface.

Java nterview questions on inheritance

Sign Up/ Sign In
Ask a Question


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki