Outputstream is an abstract class so we cannot instantiate it.Why then a default constructor is provided for Outputstream class?

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

Jon Skeet
people
quotationmark

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.

people

See more on this question at Stackoverflow