When our Buddies (Fresher’s) go for Technical
Round in Interviews, They always have lotof confusion
About very basic questions which are related
with Basic OOPS, Here I am not saying that they don’t know what the answers of
these questions are.
Here I am just trying to discuss with you, how
we can answer in frequent way or in that way, Interviewer wants to hear.
So Let us start.
Question - What is OOPs?
Oops is a system modeling technique in which a
system is design in terms of discrete objects which Incorporates with each other
to form entire system.
Let’s discuss with an Example.
A car is a system, if we want to develop this
system?
What will we need to develop this?
As we all know, We require – Tires, Engine, Gear
,Seats ,Steering etc…..
We can treat these parts as object which
incorporates with each other to form entire system (Car).
Tires + Engine + Gear + Seats + other parts= Car
(System)
Now we are moving towards a very important
question which usually ask in plenty of ways like -
Question
– Pillars of OOPs Or Properties of OOPS Or Features of OOPs
Mainly these are four Pillars of OOPS
1-
Abstraction
2-
Encapsulation
3-
Inheritance
4- Polymorphism
In this article we will try to understand these properties with
help of real world examples or very small examples.
We will discuss on these topics deeply in next article.
1-
Abstraction-
In sort we can say that showing
only relevant information is called Abstraction.
Let’s discuss abstraction with real world
example.
Example-
Let’s suppose that your father is
going to buy a car along with you and your grandfather,So obviously there will
be a Salesman at car showroom who will explain to you about the propertiesof
car. He will work very smartly like
1- When he will interact with you then he will talk about the color, pic up of the car means he will explain all these things which suits your style
2-When Same Sales man interacts with your father then he will tell him about EMI of the car.
3-When he will interact with your grandfather then he will tell him about the comfort of the car, how comfortable It is?
1- When he will interact with you then he will talk about the color, pic up of the car means he will explain all these things which suits your style
2-When Same Sales man interacts with your father then he will tell him about EMI of the car.
3-When he will interact with your grandfather then he will tell him about the comfort of the car, how comfortable It is?
So you can feel in this example how Salesman
smartly putting the only relevant information in front of every individual.
-------------------------------------------------------------------------------------------------------------
2-Encapsulation:
In one line we can say that wrapping the data into single unit is called
Encapsulation.
Note - There is one more question which could be
raised?
How we can do Encapsulation?
So answer of this question is - we can do
encapsulation with the help of Access Specifire.
There are five access specifier in C#
a-
Private
b-
Public
c-
Protected
d-
Internal
e- Protected Internal
We will discuss about these access specifier
deeply in our next article.
3-Inheritance:
With the help of this property, a class can acquire the features of another
class.
Inheritance is confine in Two Terms:
·
Parent Class or Base Class
·
Child Class or Derived Class
Let’s discuss inheritance with real world
example.
We can take the example of relation between
Computer and Laptop.
Computers invented firstly , we can treat as Parent Class or Base
Class, It have some features, after that Laptop invented ,we can treat laptop as
Child class , It contain all the basic features of computer(Base Class) along
with own extra features.
Types of Inheritance:
1-
Single Inheritance
2-
Multiple Inheritance
3-
Multilevel Inheritance
4-
Hierarchy Inheritance
5-
Hybrid Inheritance
We will discuss about these all above
Inheritances in our next Article.
-----------------------------------------------------------------------------------------------------------
4-Polymorphism:
Ability to take more than one form is called polymorphism.
Example of Polymorphism:
a)- Method Overloading (Compile Time
Polymorphism)
b)-Method Overriding (Run Time Polymorphism)