0% found this document useful (0 votes)
21 views2 pages

Difference Between Abstract Class and Interface and Its Implementation

Abstract classes can contain abstract and non-abstract methods and provide a partial implementation for subclasses, while interfaces contain only abstract method signatures and define a contract for implementing classes; interfaces support multiple inheritance and can provide implementations for abstract classes, whereas abstract classes can only inherit from one parent class and provide implementations for interfaces.

Uploaded by

Gagan Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Difference Between Abstract Class and Interface and Its Implementation

Abstract classes can contain abstract and non-abstract methods and provide a partial implementation for subclasses, while interfaces contain only abstract method signatures and define a contract for implementing classes; interfaces support multiple inheritance and can provide implementations for abstract classes, whereas abstract classes can only inherit from one parent class and provide implementations for interfaces.

Uploaded by

Gagan Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Difference between Abstract class and interface and its implementation.

Abstract class can contain one or more method signatures that themselves are
declared as abstract. Abstract classes are useful when creating components
because they allow you specify an invariant level of functionality in some
methods.
Interfaces are a special kind of type in C# used to define the specification that
should be followed by its sub-types. An interface can be defined using the
interface keyword.

The difference between Abstract Class and Interface is as follows:


Abstract Class Interface

Abstract class can have abstract and non- Interface can have only


abstract methods. abstract methods.
Abstract class doesn't support multiple Interface supports multiple
inheritance. inheritance.
Abstract class can have final, non-final, Interface has only static and final
static and non-static variables. variables.
Abstract class can provide the Interface can’t provide the
implementation of interface. implementation of abstract class.
The abstract keyword used to declare The interface keyword is used to
abstract class. declare interface.

Example of Abstract Class


public abstract class Shape
{
public abstract void draw();
}
Example of Interface
public interface Drawable
{
void draw();
}

You might also like