Object Oriented Programming Language

 What is Object oriented programing ?

  • Object-oriented programming AKA OOP's is a programmatical concept which is used in most of modern programming languages as a building block such as C#, Python ,Ruby etc.
  • Languages based on OOPs are basically working on classes and their objects.

Characteristics of Object-Oriented Programming 

 Object-oriented programing has 5 main characteristics  as below: 

  • Classes and Objects: 
For the simple definition, we can say that classes are the blueprints using which we can design the shape and structure of the object. 
An object is an instance of the class where the properties of the class are the state of the object and methods and function of the class are the behavior of the object. 

Let's understand the above definitions with a real-world example:
Assume that you are writing a program on a school application to store school data, so before working any operation on school data we need to create a structure or you can say model of the school where we need to define how our school data will look like. So to achieve that we can create a class of school because "Class is a blueprint to store state and behavior of object". 




Once we are done with our blueprint i.e. class than we can create an instance of it that is known as an object. 
For objects, the properties of the class will be its state and methods of the class will be its behavior. 



  • Abstraction:

Abstraction is the second pillar of the OOP's. Abstraction states hiding unnecessary data from the user and only displaying the required data.

API are an example of the abstraction where the user can only consume the API but the implementation of API is unknown to the user.  

We can achieve the abstraction using an access specifier in C#

  • Encapsulation:
Hiding the unnecessary data from the user and only displaying the required data to the user using public methods. 

How Encapsulation is Different from Abstraction?

  • Inheritance:
Inheritance is process in which one class can acquire data members of another class. 
The class which will donates it data member can be called as  Parent class/Base class/Super class and the class which will acquire the data member can be called as child class/derived class/Sub class. 

Types of Inheritance 

  • Single Inheritance 
Single Inheritance is a type of inheritance in which there is only one Parent class and only one Child class. Some places single inheritance is also known as single-level inheritance. 
  • Multilevel Inheritance: In multilevel inheritance there will be a child class and that child class will have one parent class but the parent class will have a parent class which mean If child class is named as C which inherit all the data members of its Parent class named as B but the class B is also inherting all the data member of a class named as A so ultimately class C will have all the data member of both class B and A. 
In the above example, there are only three levels A -> B-> C but in an actual project, there could be n number of levels. 
  • Multiple Inheritance: When a child class will implements more than one parent then that type of inheritance will known as multiple inheritance. 
Important point: we can't implement multiple inheritance only using class as compiler will throw error and restrict us to create multiple inheritance using class. 

Because if have multiple parent classes than there can be issue of ambiguity method. To prevent this compiler will restrict multiple inheritance using class. But we can Implement multiple inheritance using Interfaces. 
  • Hybrid Inheritance: Hybrid Inheritance is the combination of all the above-mentioned inheritance.


0 Comments