Hello, We need a constructor to instantiate, in the sence, to allocate memory for a perticular instance, but Interfaces are never instantiated, cause they are by default abstract. So having a constructor is not needed. Regards.
SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Thanks. But can u explain why actually the constructor is not inherited ? Upon thinking on your reply i formed this opinion.
"Actually the constructor is no where related to the object. An object constitutes of properties & behaviour, i.e fields & methods. A class extending another class inherits the actual characteristics of the object, of which the constructor is not part of. Constructor is not a part of object, it's a feature provided by java."
Your thoughts will be helpful.
If you think you can, you can. If you think you can't, you are right.
The constructor is executed everytime an object is instantiated. So if we want any properties of the class to be added dynamically when the object is created we specify them in constructor.
So the constructor is specific to a particular class.
What happens if we inherit a constructor? If the constructor is inherited then the constructor should behave as a method which it is not.That is why we cant call the constructor using a reference as we call method. So I think for the above reason constructor is not inherited. Please let me know if am wrong.
Thanks & regards, Charan.
Poop goes in a willow feeder. Wipe with this tiny ad: