Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
abstract classes and interface are similar but abstract classes modification is

possible.interface modification is not possible actually what happen whenever

Add method in abstract classes or interface

What I have tried:

.
Posted
Updated 18-Feb-18 21:47pm
v2
Comments
Daniele Rota Nodari 19-Feb-18 3:30am    
What do you mean with "modification" ?

Where did you get the idea that abstract classes could be modified but interfaces can't?
The difference is that interfaces can define no code at all, they just set out the signatures that a calls must implement in order to add the interface. Interfaces are not classes, they are a "membership contract" which when followed allows the immplementing class to become a "member of the interface's club".
An abstract class can define code, which can be overridden in derived classes. An abstract class is a full class, with the proviso that an abstract class cannot be instantiated: you cannot new the new keyword directly on an abstract class.

The difference allows a class to be derived from - for example - Control, but also implement an interface such as IEnumerable which permits it to be used in a foreach loop.

Abstract classes and interfaces are not the same, and neither can be "modified" without changing the source code for the abstract class or interface.
 
Share this answer
 
 
Share this answer
 
An interface is not a class, see explanation here: Abstract Class versus Interface[^]
 
Share this answer
 

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