Well lets not get far away to get a practical use. Take java.util.Calendar for example. It is an abstract class. So it provides implementation for most of the methods leaving a few. The ones left are too specific for a generic calendar to implement. But java.util.Collection is an interface as everything related to it is too specific for a generic collection to implement...
can you tell me a difference between abstarct class and interface with proper real time example.
Interfaces are used to add optional behaviour in class. Consider Comparable interface that allows a class to make sure that its instances are ordered with respect to other mutually comparable objects. Such interface is called a Mixin. You cannot define Abstract Classes as mixin.
I have read all the reply's, but for me this is the explanation:
The basic difference is that an interface is like a 100% abstract class, that means ALL of his methods are abstract, ALL. But an Abstract class can have, non Abstract methods too, so you have an specific behaviour, this is one's of the differences, think about it, you are getting a more specific behaviour with an abstract class.
The other difference is that in JAVA you can not extend more than one class, if you make an abstract class, you have to extend it, and you can not extend any other class, you loose that posibility. But is different with an interface, you can implement one or more interfaces, and have the posibility to extend any other class, so is more flexible, depends on what you need.
Interfaces are used to add optional behaviour in class.
Not optional behavior. Having a class implement an interface means that you're saying that the class will perform behaviors (methods) specified by the interface.
Ohh... you didn't understand my point. Let takes an example of Serialization. Its an optional behavior for any class to implement, but ones implemented, offcourse it becomes necessary for a class to implement all those methods defined in Interface.