When we will use an Interface and Abstract class

Showing Answers 1 - 6 of 6 Answers

Interface:

Code resuability

Acheive multiple inheritence

If u can add any method that does not effect the class


Abstarction

If u does not want instance of the class then we go for bstartcion

  Was this answer useful?  Yes

When To use Interface:

An interface allows somebody to start from scratch to implement your interface(or) implement your interface in some other code whose original or primary purpose was quite different from your interface. To them, your interface is only incidental, something that have to add on to the their code to be able to use your package

When to use Abstract:

An abstract class provides more structure. It usually defines some default implementations and provides some tools useful for a full implementation. The catch is, code using it  must use your class as the base. That may be highly inconvenient if the other programmers wanting to use your package have already developed their own class hierarchy independently. In Java, a class can inherit from only one base class.
                                                                                            Delivered By
                                                                                                 
                                                                                  konnipati.sivakumar


  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions