Why does OutputStream provide a constructor if its abstract?
Joined: Nov 29, 2001
What is the purpose of defining a no-arg constructor in this class? Thanks
Joined: Aug 26, 2001
If you look at the source code of OutputStream.java you'll notice that in fact they didn't define any constructor at all. The compiler thus added the default (no-arg) one which is reflected in the API. Since OutputStream is abstract you can't instantiate it directly anyway. I think it would have made more sense here to define one protected default constructor... ------------------ Valentin Crettaz Sun Certified Programmer for Java 2 Platform
hi jim, sometimes we need constructor in an abstract class too as it can have some methods implemented except atleast one abstract methods and can have instance variable shared by all the subclasses that needs to be initialized. so we can have constructor in the abstract class. hth; regards maulin