I was being troubled by the concept of abstract class.i can't understand that let us take an example abstact class "InputStream" .we can implement method read(byte[]) with it's reference. how does this method is being refferred by it's abstract class as there will be no instantiation to this abstact class.

Recommended Answers

All 3 Replies

You will instantiate a class the extends from InputStream. The class will have implementation of the abstract methods.

u just keep in mind one thing that if whenever there is a function called by the reference of an abstract class the only reason for this is that reference has been aassigned the INSTANCE of derived class. IT'S NOT THAT ALL THE FUNCTIONS OF AN ABSTRACT CLASS ARE ABSTRACT OR PURELY VIRTUAL OR DON'T HAVE DEFINITION SO THAT THEY SHOULD ALWAYS BE DEFINED IN THE DERIVED CLASS.
ANY CLASS HAVING ATLEAST ONE ABSTRACT FUNCTION(function with no definition) IS AN ABSTRACT CLASS.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.