Hi kaveri
Both Abstarct classes and Interfaces have there own significance.1 thing i would like clarify before comming to your doubt that Interfaces are not the replacement of multiple inheritence
Let me give a wonder full example to elaborate ur doubt
vechicle
|
four wheeler
|
car
we have a heirarchy like i have shown above In this case vechile SHOULD BE ABSTRACT CLASS
now
Think of this scenario
clothes
|
above waist
|
t-shirt
This is also self explanatroy and in this case also the clothes should be abstract class
Now we have seen two hierarchies ,where does the interfaces comes in picture?
see
We have a class called sporty and another class called formal
Our concreate class
car can be a sporty car(ferrari) or a formal car(Mercedez benz)
Isn't it?
And at the same time our t-shirt can be a formal t-shirt(duke) or sporty t-shirt(nike)
vechicle
|
four wheeler
|
car
||
sporty
||
clothes
|
above waist
|
t-shirt
Word interface says it all interface means somthing acting as a adapter between two unknown things
Ok
Here's a better example
YoU HAVE A GAME APPLICATION BRICKS
where this application is a gaming application you want it to be a multithreaded application.Reason being this class is doing multiple tasks together
ball moving
bar moving
bricks falling
So what will u do to give it a multithreaded effect
extends
Thread and boom U are denying app from using if any requried gaming effect class.
So what will you do
class BricksApplication extends GenericBrickApp implements Runnable
So your application is multithreaded gaming application
The adjective effect given by multithreaded keyword signifies interface
I know its exhaustive u might have never reached this sentence but i cant help it this is my favorite topic
in case of any doubt please post a reply
regards
Nishant