Author | Topic: final classes |
jvarkha greenhorn |
posted April 27, 2000 07:03 AM
Hi, As far as I understand, final classes cannot be subclassed. So you cannot create an instance of Math class or make another class extend Math class. Wrapper classes (Integer,Double etc) are also final, but how come we're creating new instances of these classes using their constructors ? I definitely am missing something here. Clarifications will be welcomed. Thanks.
|
Robin unregistered |
posted April 27, 2000 07:38 AM
Hi jvarkha, final classes can't be subclassed,but they can be instantiated. Math class is static final so u won't create objects of this class but directly call its methods like Math.random() etc.
|
maha anna bartender |
posted April 27, 2000 08:12 AM
Robin, Your reason is not exactly true why we can't create objects of Math class. It is because Math class's constructor is kept private regds [This message has been edited by maha anna (edited April 27, 2000).]
|
jvarkha greenhorn |
posted April 27, 2000 08:13 AM
Thanks Robin, you cleared my doubt.
|
jvarkha greenhorn |
posted April 27, 2000 08:23 AM
HI Maha Anna, I missed your response, but Thanks a lot for the clarification. So the important factor here is the visibility of the constructor. Thanks.
|
| | |