here is the link for API documentation of Outputstream abstract class .You will find a default constructor
http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html#OutputStream%28%29
The class has to have at least one constructor, because all Java classes have constructors. Additionally, subclasses will have to chain to it - so it's got to be at least protected
accessibility. The constructor doesn't need to do anything, so the authors decided not to provide an explicit one. Now, from JLS 8.8.9:
The default constructor has the same accessibility as the class
That's why it's public
. It could have been explicitly provided as:
protected OutputStream() {
}
... or better yet, the JLS could have made it so that public abstract class default constructors were implicitly protected. However, it does no harm for it to be public.
The default constructor is always present in every java class, if there is no other constructor defined. This makes sense, since you need to have some way to instantiate the class. For abstract classes there still needs to be a constructor that can be called by the constructors of the sub-classes. Even if you do not explicitly write a super()
statement as the first statement of a constructor, it is implicitly added by the compiler and executed at runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With