C# and .NET OOP (Object oriented  programming) interview questions – Abstract classes and interfaces.

C# and .NET OOP (Object oriented  programming) interview questions -Abstract classes and interfaces.

I have yet to remember a .NET interviewer who never asked about abstract classes,  interfaces and object oriented interview questions . I am putting forward questions which comes around abstract classes and interfaces again and again…Hope every one benefits.

Normally the C# interviewer starts with…..

What is abstract class ?

Abstract class is a base class or a parent class. Abstract classes can  have empty abstract methods or it can have implemented methods which can be overridden by child classes.

The next question i expected
was on interfaces and yes there it comes.

What are interfaces?

Interface is a contract class with empty methods , properties and functions.Any class which implements the interface has to compulsory implement all the empty methods , functions and properties of the interface.

Now the 1000% sure
question was bound to come difference between them…

What’s the difference between abstract class and interface?

There are many differences, below are some key two differences :-

  • Abstract class are base class or parent class while interfaces are contracts.
  • Abstract class can have some implemented methods and functions while interfaces methods and functions are completely empty.
  • Abstract classes are inherited while interfaces are implemented.
  • Abstract classes are used when we want to increase reusability in inheritance while interfaces are used to force a contract.

Can we create a object of abstract class or interface?

No we can not.

Now the practical

In what scenarios will you use a abstract class and in what scenarios will you use a  interface?

If you want to increase reusability in inheritance then abstract classes are good. If you want implement or force some methods across classes must be for uniformity you can use a interface. So to increase  reusability via inheritance use abstract class as it is nothing but a base class and to force methods use interfaces.

Really friends having C#  experience is one thing and cracking
Dot net  and C# interviews is a different ball game all together .


About c# and .NET Interview questions

This blog is for developers who want to crack .NET and C# interviews. It has all tips and tricks needed to crack .NET interviews , C# interview , SQL Server interview , Java interview , WCF Interview , Silverlight interview , WPF interview , LINQ interview , Entity framework Interview. Do not forget to watch our Learn step by step video series. Learn MVC in 16 hours:- https://www.youtube.com/watch?v=Lp7nSImO5vk Learn AngularJS Step by Step:- https://www.youtube.com/watch?v=0kmdjqgO9IY Learn Design Pattern in 8 hours:- https://www.youtube.com/watch?v=YDobmucohqk Learn C# and .NET in 60 days:- https://www.youtube.com/watch?v=yh2SrzCkNQA Learn MSBI in 32 hours:- https://www.youtube.com/watch?v=mGPJx3ocFgg Learn SharePoint Step by Step in 8 hours:- https://youtu.be/C2fW76SwJNU
This entry was posted in Uncategorized and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s