Why does OutputStream provide a constructor if its abstract?
Jim Hall
Ranch Hand
Joined: Nov 29, 2001
Posts: 162
posted
0
What is the purpose of defining a no-arg constructor in this class? Thanks
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
posted
0
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