Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java Language
Expertise: Beginner
Aug 11, 2000

Interface vs. Abstract Class

Question:
What is the difference between an interface and an abstract class?

Answer:
Within the confines of Java syntax, an interface is a type that only defines abstract methods and constant members. In a more general sense, an interface is an abstract class that defines no implementation. Neither an interface nor an abstract class can be directly instantiated. However, an abstract class may define non-constant members and non-abstract methods. An abstract class is often used to define the common set of features required of its implementing subclasses, including data structures and method implementations. An interface is used to define only the methods and constants that are to be shared by its implementers. You may implement an interface using the implements keyword and extend an abstract class using the extends keyword. When you implement an interface, you must provide the code for all of the methods in the interface. When you extend an abstract class, you inherit all of the implemented methods and only need to implement those that were left undefined (abstract).

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date