OOPS is a programming paradigm based on the objects, which can contain the data and code.OOPS is a way to build the softwares budeled with objects that interact with each other. The main concepts of OOPS are,
A class is a blueprint of object, which describes the behavior of the object. We can take Vehicle as the class.
Object is the instance of class. Any real world entity like car, bike can be considered as an object.
Abstraction is used to hide the implementation details and show only the required details to the user. Which allows the user to add more complex code without knowing the underlying complexity of the existing code. We can also take Black Box as the example of abstraction.
The Ability to respond in more than one form in known as polymorphism. For example we have print method we can override that method and do some other operations with default print method.
There are two types of polymorphism,
The method of linking an function with object during runtime is called as runtime polymorphism. funciton overriding is example of runtime polymorphism
Function Overriding — The Process overriding the exisisting functionality of a method is known as function overriding. We can have a method in base class and we can change to functionality in the derived class by overriding it in derrived class. The parameters and return type should be the same in parent and base class.
The method of linking a function to object during compile time is known as compiletime polymorphism.
Function Overloading — It is the way of providing the additional functionality to the existing function name. We can have same name but different signature.
Encapsulation is binding the data and methods into a single entity. The data and methods are encapsulated to add the security to the code.They can be used but can not be modified by outer world. Abstraction is implemented with the Encapsulation.It solves the problem at implementation level. Data hiding can achieved by using access specifiers,
Public — The code is accessible any where from outer world
Private — The code is accessible only with in the same class.
Protected — The code can be accessed only by the inheriting child class.
Internal — The code can be accessed anywhere in the same assembly.
Protected Internal — The class can be accessed by code in same assembly and child classes.
Private Protected — The private protected over comes the limitation of protected internal, the derrived class from differnt assembly can not access the code.
Inheriting the parent class properites in child class in known as Inheritance. There are 5 types of Inheritence in C#.
Multiple Inheritence(Through Interfaces)
There will be a seperate story explaining the inheritance, Stay tuned. These are the basics concepts of Object Oriented Programming.