Saturday, 18 April 2020

PILLARS OF OOPS

What is OOPS ?
Object Oriented Programming is the concept language which is an extension to the c language , the concepts gives a edge to the user over the c features and allows the the user to perform the functions which one cant perform in c language
 OOPS basically refers to the language which uses objects in programming . OOPs aim is  to implement many real-world entities and features such as  like inheritance, hiding, polymorphics etc in programming.
The main aim of OOPS is very vast and to provide more features than in C , but also some aims are to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.
BASIC OOPS CONCEPTS :
 Polymorphism
 Inheritance
 Encapsulation
 Abstraction
 Class
 Object
Method
Message passing
What are OOPs 4 main pilllar ?
The 4 main pillar of OOPs are the following Encapsulation, Data Abstraction, Polymorphism and Inheritance. so lets start ....
1) Encapsulation
   
Encapsulation is actually a mechanism of hiding of data implementation in many ways such as  restricting access to public methods. Instance variables are kept private and accessor methods are made public to achieve this.
Some other way to understand about encapsulation is, it is a protective shield that prevents the data from being accessed from outside this shield.
the variables or data of a class is restricted from any other class and can be accessed only through any member function of own class in which they are declared.
Encapsulation can be achieved by many ways such as  Declaring all the variables in the class as private and writing public methods in the class to set and get the values of variables
2) Data Abstraction
 It is a process of identifying only the required characteristics of an object ignoring the irrelevant details or any other materials.
The properties and behaviors of an object differentiate it from other objects of similar type and also help in classifying/grouping the objects.
In java language, abstraction is achieved by interface and abstract classes. We can achieve 100% abstraction using interfaces.
3) Polymorphism
 polymorphism actually means having many different forms or ways ,in other words or simple words we may define it as the ability of a message to be displayed in one or more form 
Polymorphism is considered as one of the important features of OOPs.
 Polymorphism allows us to perform a single action in different ways.
In other words, polymorphism allows you to define one interface and have multiple implementations.
 The word itself means  “poly” means many and “morphs” means forms, So it means many forms.
4) Inheritance
Inheritance is an important and main  pillar of OOP It is the mechanism / method  in java by which one class is allow to inherit the features(fields and methods) of another class.
Some important terminology :
Super Class: Super class whose features are inherited is known as super class.
Sub Class:  class that inherits the other class is known as sub class.The subclass can add its own fields and methods in addition to the superclass fields and methods.
 Inheritance supports the concept of “reusability”, for example  when we want to create a new class and there is already a class that includes some of the code that we want, derive our new class from the existing class. By doing this, we are reusing the fields and methods of the existing class.
REFERENCES
[1]Tutorials Point -https://www.tutorialspoint.com/


[2] GeeksforGeeks - https://www.geeksforgeeks.org/
[3]https://beginnersbook.com/2013/04/oops-concepts/

1 comment: