Hi ! Constructors cannot be inherited because they are different from ordinary methods, they are called when the class is instantiated. The sub-class can invoke the methods of the super class and not he contructor. Thanx Afroz.
If a class can access the super class constructors and methods then why we say that this class can not inherit its super class constructors. I know you can not override a Constructor, which means you can not add a new feature to the constructor. But as long as you are able to access it can't we say we are inheriting it. Can someone put more thoughts in it........
Hi , if u look into JLS, 8.8 constructor delclarations, u will get an answer for ur question. I have copied the the reqd part here..
Constructors are invoked by class instance creation expressions (�15.9), by the conversions and concatenations caused by the string concatenation operator + (�15.18.1), and by explicit constructor invocations from other constructors (�8.8.5). Constructors are never invoked by method invocation expressions (�15.12). Access to constructors is governed by access modifiers (�6.6). This is useful, for example, in preventing instantiation by declaring an inaccessible constructor (�8.8.8). Constructor declarations are not members. They are never inherited and therefore are not subject to hiding or overriding.
thanks, Baskaran --------------------------------------------- [This message has been edited by Baskaran Subramani (edited September 06, 2000).]
Wink, wink, nudge, nudge, say no more, it's a tiny ad: