In early years there was linear programming and procedure oriented programming. In Procedure Oriented Programming, member variable and method of class execute separately, so execution process of procedure oriented programming was slow. And a big drawback with procedure oriented programming was we cannot reuse the code which has executed once. Suppose there is one class Student as in the following code snippet:
- Class Student
- Int Sid;
- String Sname, Sadress;
- Public void Get()
- {
- Console.Write(“Enter the Student Id, Name and Address”);
- Sid = convert.ToInt32(Console.ReadLine());
- Sname = Console.ReadLine();
- Sadress = Console.ReadLine();
- }
- Public void Display()
- {
- Console.WriteLine(“Student Id is: ”this.Sid);
- Console.WriteLine(“Student Name is: ”this.Sname);
- Console.WriteLine(“Student Address is: ”this.Sadress);
- }
- }
- Class Details
- Public void Main(); {
- Student obj = new Student();
- Obj.get;
- Obj.Display();
- }
- Console.ReadLine();
- }
- }
In this Class if we required displaying the detail of course together with Student, then we required to write the Program for Class Student once again along with Course Class. So it was a waste of resources, since developer has developed Object Oriented programming language that consider each and everything as Entity.
Oop provide reusability of code in object oriented programming language member variable and method execute together so the code execution in .NET is faster than procedure oriented programming language code.
Properties
Properties of object oriented programming language are:
- Inheritance
- Encapsulation
- Polymorphism
- Abstraction
The Properties of OOP shown graphically in the following figure.
Figure: OOP Properties
Inheritance
Inheritance is a process of deriving new class from the class which already exists.. There are five types of Inheritance:
- Single Inheritance
- Multilevel Inheritance
- Multiple Inheritances
- Hybrid Inheritance
- Hierarchical Inheritance
Polymorphism
Polymorphism means “Many forms”, When one method behaves in different forms it is known as Polymorphism. Also, new implementation of same method with different signature is known as Function Overloading. There are the following two types of Polymorphism.
- Static Polymorphism
- Dynamic Polymorphism
Encapsulation
Encapsulation is a process of binding member variable and method of a class together. In object oriented programming language member variable and method of a class execute together, so code execution in object oriented programming language code is faster than procedure oriented programming language code.
Abstraction
Hiding the implementation and providing services to user is known as Abstraction.
Recap
Object oriented programming language provides the reusability of code and the execution of object oriented programming language code is faster than procedure oriented programming language code.
The properties of Object oriented programming Language are the following:
- Inheritance
- Encapsulation
- Polymorphism
- Abstraction