This Angular tutorial helps you get started with Angular quickly and effectively through many practical examples.

Interface and Abstract Class Questions


In this article we are going to discuss some important Questions regarding Interface and abstract in C#.

Que 1: Can we define body of Interfaces methods? When to define methods in Interfaces?

Yes. From C# 8.0 it is possible to put method bodies in Interfaces. Before C# 8.0 it is not possible to put method bodies in Interfaces.

Interface and Abstract Class Questions in C#

Que 2: Can you create an instance of an Abstract class or an Interface?

No. Abstract class and interface purpose is to act as base class via inheritance. There object creation is not possible.

Interface and Abstract Class Questions in C#
 Interface and Abstract Class Questions in C#

Que 3: Do Interface can have a constructor?

NO. Interface can only be used for inheritance, so constructor is not required.

Interface and Abstract Class Questions in C#

Que 4: Do abstract class have Constructors in C#?

YES, Abstract class can have constructors. The reason is, when the abstract class is inherited in the derived class, and whenever the object of the derived class is created then FIRST the constructor of the abstract/ base class will be called and then only the constructor of derived class will be called.

Interface and Abstract Class Questions in C# Interface and Abstract Class Questions in C#

Que 5: What is the difference between abstraction and abstract class?

-Abstraction means showing only required things and hide the BACKGROUND details.
-Abstract class is one of the ways to implement abstraction

Que 6: Can Abstract class be Sealed or Static in C#?

NO. Abstract class are used for inheritance, but sealed and static both will not allow the class to be inherited.

Interface and Abstract Class Questions in C#

Que 7: Can you declare abstract methods as private in C#?

NO. Abstract methods are only declaration, and they must be implemented in the derive class, therefore they can not be private.

Interface and Abstract Class Questions in C#

Que 8: Does Abstract class support multiple Inheritance?

NO. Only at maximum one abstract class can be used for inheritance. But multiple interfaces can be used.

Interface and Abstract Class Questions in C#
Prev Next