Monday 23 December 2013

what is the difference between interface and abstract class?


what is the difference between interface and abstract class?

interface:
1.any specification requirement service is called interface.for example sun people develop a jdbc API and the implementation is given by vendors.
2.If we don't know anything about the implementation and we should know only specific requirements then we should go for interface.
3.we are defining every method in a interface as public and abstract.whether we are declaring or not a method in a interface.
4.In interface only contain declaration but it does not contain any implementation.
5.In interface we can use a keyword implements.
6.In interface we are declaring any variable as public static final
7.we cannot declare the interface methods with modifiers private,protected,final,static.
8.inside interface we cannot take constructor
9.inside interface we cannot take static and instance blocks.

abstract class:
1.An abstract  class contain abstract methods and non abstract methods.
2.If we know about the implementation but not purely and we specific requirements then we should go for abstract class.
3.In abstract class declaring of every method need not be a public and static.
4.In abstract class we can use the keyword extends
5.In the abstract class we can take constructor.
6.Inside of the abstract class we can take static and instance blocks.
7.By using abstract class we can extends only one class.
8.It is not require to perform the initialization of the variable.
About Admin of the Blog:

Krishna babu is the founder of Alljobupdates .He is a Tech Geek,SEO Expert,Web Designer and a Pro Blogger. Contact Him Here

Follow him @ Facebook

0 comments:

Enjoyed? Share Your View With Us