when to use abstract class and when to use interface?
Answer Posted / rod
the bowlingball example I put is when you combine the
abstract class ball with the interface bowlable .. a poor
example perhaps.. lets replace that with
a sock may implement a washable interface which can also be
implemented by cars, shirts, dishes... etc.. so why bother
with this. The reason is for future use as the system grows.
It is more likely that you will run into an object that
needs to be 'washed' then you can in fact call this method
without knowing the lower level details.
its more than just organising things that do or are acted
upon by the same conceptual action. It means that later you
can just use the method because the interface populates the
list of things you can choose from at code completion in the
editor ..for example.
| Is This Answer Correct ? | 3 Yes | 6 No |
Post New Answer View All Answers
Can we declare an array without size in java?
How many bits is size_t?
What's the difference between comparison done by equals method and == operator?
What is a boolean used for?
What is math in java?
What is nested loop? What is dangling else condition in it?
how to open and edit XML file in Weblogic???
What is an infinite loop?
What is difference between ++ I and I ++ in java?
what r advatages of websphere? & how to deploy?
Can we create our own daemon thread?
What is the maximum size of list in java?
Is string passed by reference in java?
Differentiate between a class and an object.
What is JDBC Driver interface?How can you retrieve data from the ResultSet