Click here to Skip to main content
15,913,090 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Difference between Abstract and Interface
Posted

The key technical differences between an abstract class and an interface are:

1. Abstract classes can have constants, members, method stubs and defined methods, whereas interfaces can only have consts and methods stubs.

2. Methods and members of an abstract class can be defined with any visibility, whereas all methods of an interface must be defined as public.

3. When inheriting an abstract class, a concrete child class must define the abstract methods, whereas an an abstract class can extend another abstract class and abstract methods from the parent class don't have to be defined.

4. Similarly, an interface extending another interface is not responsible for implementing methods from the parent interface. This is because interfaces cannot define any implementation.

5. A child class can only extend a single abstract (or any other) class, whereas an interface can extend or a class can implement multiple other interfaces.

6. A child class can define abstract methods with the same or less restrictive visibility, whereas a class implementing an interface must define the methods with the exact same visibility.
 
Share this answer
 
Comments
Deepu S Nair 18-Feb-15 2:09am    
Two solutions for a single question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900