Hello, Here is difference between Interfaces and Abstract Class 1. Interfaces can't have any method implementation, where as Abstrcat class can have method implementation. 2. Abstract class must be inherited, and give implementation for methods declared abstract, otherwise the derived class must be also declare Abstract, whereas Interfaces and implemented by class(implements iterface_name). If class implements any interface, it must give implementation for all method declared in Iterface. 3. A class can on extend from only one Abstrcat class(or concrete class), but a class can implement 2 or more Interfaces 4. Interfaces helps in adding types to class, this is not with abstract class. 5. Interface can be used to establish relation between unrelated class. 6. Interface helps in writing future safe code, it also facilites writing generic code. Though there is no method implemented in interface, it is very helpful. There is some thing called Tagging Interface which do not have any method, it just helps in marking the class for that interface. e.g. Serializable is tagging interface with no method. Regards,
Hi! Vasanthi An abstract class can have non abstract methods where as in an interface all its methods are abstract by the virtue of the fact that an interface only defines method prototypes and not their implementation Hope this helps.
Originally posted by vasanthi: Hello everybody, I am preparing for the scjp exam,can anybody tell me the difference between interface and an abstract class,i am just confused.Please help me. regards vasanthi
Vasanthi, Didn't you post the same question here?? Since these two are duplicate threads, I am going to close this one and invite others to continue the discussion, if need be, in the old thread. Thanks! Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
a bit of art, as a gift, the permaculture playing cards