Thursday 27 February 2014

What is Difference between Abstraction and interface in oops

Oops interface vs abstract class:

Interface only signature of functionality, and if we have some common methods as well as common signature then there is a need of abstract class.  and  abstract class we can provide behavior as well as functionality both in the same time, developers can use inheriting abstract class  this functionality and need to fill only in the empty.





Interface:

Contract interface: The interface write the guy say "hey, I accept the way things are looking so", and the guy using the interface says "OK, looks class I wrote that way".

Interface is an empty shell, but not the signature (type name / parameters / return) of these methods. Methods do not have anything. The interface can not do anything. It's just a pattern ....

E.G 


Interface


Abstract Class:

We create abstract class then we redefine. we can not create object in abstract class but create object in derive class object.
 Abstract classes, unlike interfaces, classes. There are more expensive to use as a look up is done when you inherit them.

E.G
Abstract Class


As usual with programming, there is theory, practice, and practice in another language.






0 comments:

Post a Comment