This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Can anyone please tell me the logic behind having concrete methods in abstract class as we cant instantiate them ?
E.g. - (Abstract Class)InputStream - has concrete method - read (byte [] b) and the subclass FileInputStream also has method -- read (byte [] b)
Now we cant create an object of InputStream as it is an abstract class then why do we have concrete method (read (byte [] b))in InputStream ? What is the use of having concrete methods in abstract class
Thanks Dhaval
Thanks and Regards,<br />Dhaval Shah<br />SCJP 1.4<br />SCWCD 1.4
It is a design decision by the programmer to enforce a particular vision of how the class is to be used. In InputStream it ensures that extending classes do not need to provide an implementation of read( byte[] ) in order to work.
You can in fact have a class declared abstract but containing all concrete methods.