Can we inherit the constructor in a Class?please give one example.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32694
4
posted
0
Originally posted by shruti patel: Can we inherit the constructor in a Class?
No
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35249
7
posted
0
How would you test whether constructors are inherited? Tell us what code you'd need to do so. Once you have the code, you can compile and run it, to see what happens.
There is another class ConstructorTry in package B
the line marked will give an error that there is no constructor in Constructor try that takes a String. If the constructor of A.ConstructorTry was inherited then the line would have compiled as A.ConstructorTry has a constructor which takes a String and B.ConstructorTry is a sub-class of A.ConstructorTry.