Fundamental of OOPS From Scratch to End
Module 1:- [Fundamental]
OOPS: -
- Oops stands for object-oriented programing structure/system.
- Before OOPS we had (POP) Procedure oriented programming structure/system.
- In POP all the work was processing in a sequence process. It became quite complex when the number of Lines of Code became large.
- When process increases, then the functionality of code also increases. The complexity also increases in POP.
- So, in OOPs all the stuff divided into small modules known as the object.
- Another thing you have to understand that the concept of object-oriented programing is derived from the Real world.
- The main concept of OOPS is Class and Object.
So, let’s see what is class: -
Class: -
The class is a collection of Data Member and Member Function. Data member are the variables which we declare into the program and Member functions are the functions or method which we declare into the program.
Quite confused... let’s see a scenario…
A man can do many things in his daily life. Like he eats, he runs, he sleeps, etc.
Here there are many people who do the same task. How can we define that person?
So this stuff can be possible with help of OOPS concept.
Let’s understand a class have name Person
That person may have some basic information. Like his id, first name last name age etc.
And he also has some functions like eating(), Run (), Sleep () etc.
So basic syntax to create a class is...
But Class is nothing without Object. Because The language itself says I am Object Oriented Programming.
Which means all the things are related and depending on the object.
Object: -
An object is an instance of the class.
It is basically used to access methods of the class which is declared in it.
So, we need an object to call the methods of that class.
Object Name can be anything but I suggest. Please give its name meaningful or related to class.
So it’s quite enough to understand the meaning of Class and object.
But Oops is not limited to only class and object
There are various areas of oops.
- Class
- Object
- Encapsulation
- Inheritance
- Polimorphism
Encapsulation: -
We had seen the capsule. What does it have it is consist of some medicine and it is covered with some out coted.
The same concept is here in Encapsulation. The definition of Encapsulation says that
“Wrapping of data member and member functions in a single unit
And that single unit is known as the class”
Encapsulation is used for Data Hiding.
Inheritance: -
A Process of deriving a new class from already derived class
The main concept of Inheritance is Reusability.
There are 5 types of inheritance
- Single Level Inheritance.
- Multi-Level Inheritance.
- Hybrid Inheritance.
- Multiple Inheritance.
- Hierarchical Inheritance.
a. Single Level Inheritance:
one base class, one derived class
b. Multi-Level Inheritance
One Base Class is deriving from another Superclass and that another Superclass is base class of another superclass.
c. Multiple Inheritance
super class are deriving a single base class.
d. Hybrid Inheritance.
combination of two or more inheritances is known as Hybrid inheritance.
e. Hierarchical Inheritance
one super class have 2 base classes. And that 2 base class have more sub classes. That tree kind of structure is known as Hierarchical inheritance.
Polymorphism: -
“Having More than one form of a same thing is known as polymorphism”
There are 2 types of inheritance.
1.CompileTime(Overloading/Static)
2.Runtime (Overriding/Dynamic)
1. Compile time polymorphism.
In this type of polymorphism, there is one class have many methods.
2. Runtime Polimorphism.
Before getting into Over Riding lets understand what ‘overriding’ key word is and what ‘virtual’ key word is.
For overriding, the base class method is derived in derived class. We have to declare a base class method as virtual and derived class method as an override.
The basic meaning of virtual is the imaginary thing. Like it is available in the program. but actually, it is not available there.
In commonly we can take an example of GOD. We believe that God is existing in every person. But what is that we don’t know. We can’t see that thing through the naked eye.
Static Key Word
- In c# anything marked as static, it means memory will be allocated to that property will be for permanent…
- When application will start the memory will allocate to that memory permanent. In c# we have 2 things as static
1. Static class
2. Static members.
- Can’t initialize and not need to initialize. In simple words, I can say that we don’t need a new keyword to create the variable of the class type.
- Class is directly accessible with its name.
- Any member which is declared in a class using static keyword is called static member.
- These are directly accessible by the name of the class name, not the instance name.
e






Comments
Post a Comment