.NET interview questions: – Show the advantages of using OOPS over functional programming?

In fact this one is the basic but very important .NET interview questions asked in almost every interview. An interviewer expects that every candidate should know and answer it. So if you are not sure about it so read the following answer thoroughly and get clear your fundamental related to OOPS.

  • Abstraction: – Abstraction filters un-necessary information from the user’s perspective. It just gives enough information to the user rather than giving him unnecessary information by which he can get confused. Abstraction can be different from different user perspective. For instance below figure ‘Abstraction perspective’ shows how a simple user looks at a television and how a TV mechanic looks at the television. From a simple user perspective he only needs to start, stop, change channels and control volume. But when a TV mechanic looks at the box he is concerned with details like CRT, Electrical Components, Wires, connection, cooling fan etc. So abstraction is about two things one is show only what is needed and second the need should be from end users perspective.
oops

Figure: – Abstraction Perspective

Ok, now how does that fit in to the software world? When we design components we should know what type of user will be using the component. Figure ‘Abstraction in action’ shows how the customer components when has different view of abstraction for the internal and external developer.

oops

Figure: – Abstraction in Action

  • Encapsulation: – Encapsulation separates an object interface from its implementation. It hides internal implementation details from the users. You can get a better feel by looking at the figure ‘Encapsulation and Abstraction’. It shows a simple stock class which allows a user to add and remove products from the stock. It also has a restock and alert in case products are out of stock. End user is only exposed to operations like ‘addstock’,’removestock’ and get the current level of the stock. He is completely isolated from auto functionalities like how the restock operation takes place. These operations are encapsulated from the end user perspective.

Note :- Abstraction means to expose the necessary functionalities while encapsulation means to hide the complexity. They both complement each other, but there is a huge difference in terms of thinking approach. In interviews ‘difference between abstraction and encapsulation’ is one of the favorites questions among interviewers. So understand the concept fundamentally as you can get in to long talks of confusion with the interviewer.

oops

Figure: – Encapsulation and Abstraction

In java or C# encapsulation is achieved by using private, public and protected access modifiers.

  • Inheritance: – OOPS is all about mapping with real world. One of the relationships in real world is parent child relationship. Inheritance is a methodology by which you can form new classes using existing classes as base. For instance figure ‘Inheritance in action’ shows we have created a parent class called as ‘ClsDisplay’. We can inherit from ‘clsDisplay’ and create bold and italic display classes.
oops

Figure: – Inheritance in action

  • Polymorphism: – Polymorphism means one object can exist in different forms. It refers to ability of the object to take different forms depending on situations. For instance we can use the ‘clsDisplay’ object to point to italic or a bold display object. So depending on the situation the parent class ‘clsDisplay’ can morph/change to any other form.
oops

Figure: – Polymorphism in action

See more on OOPS in video from describing implementation of Aggregation, Association and Composition as follows: –

Visit to get more stuff on interview questions and answers for .NET

Regards,

Also visit for more author’s other blogs on Most asked .NET interview questions

Advertisements

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.

One Response to .NET interview questions: – Show the advantages of using OOPS over functional programming?

  1. srishti says:

    useful post indeed.. being enrolled in OOPS, .NET and SQL Server Interview Preparation Course @ http://www.wiziq.com/course/46-INTERVIEW-PREPARATION-COURSE-BY-SHIVPRASAD-KOIRALA I was looking for such post to help me with dot net.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s