i have read some lines from somewhere but i cant understand the meaning of this line clearly .. i dont know why i cant understand. I know the difference between this two very well.. But plz help me .. and explain that what it does mean… ?
In design, you want the base class to present only an interface for its
derived classes. This means, you don’t
want anyone to actually instantiate an
object of the base class. You only
want to upcast to it (implicit
upcasting, which gives you polymorphic
behaviour), so that its interface can
be used. This is accomplished by
making that class abstract using the
abstract keyword. If anyone tries to
make an object of an abstract class,
the compiler prevents it.
Thanks in advance….
You want people to refer to animals as Animal, rather than specifically Dog or Duck. That way, if you breed a dog/duck hybrid, and thus a new type of animal is created, they don’t have to go around changing code to deal with this new wonder.
The interface they are speaking about in your quote is not talking about a Java ‘interface’ but rather ‘a collection of methods you may use to interact with this object’.
All animals speak, and that’s what important. It’s the interface. Exactly how they speak is an implementation detail.