Both interface and an abstract class cannot be instantiated and are implemented
by inheriting them in other classes.
The differences between them are:
a)All members are public by default.
b)They cannot contain fields.
c)No coding of the methods or the properties is allowed.
d)They do not provide implementation.
e)Interfaces support multiple inheritance
f)abstract keyword is not there before the interface or its members names.
a)All members are private by default. We can put modifiers like
public, protected before the abstract class members.
b)They can contain fields.
c) coding of the methods or the properties is allowed.(nonabstract)
we can also declare abstract methods(methods with no coding) and only
d)They can provide implementation. An abstract class can implement an
e)Abstract classes support single inherritance
g)abstract keyword is required before their names and also before the
abstract methods or properties.
Asked In: Many Interviews |