Oops concept :-
The full name of OOP is object-oriented programming. Following are the OOPS concepts:-
Object
Class Encapsulation Abstraction inheritance Polymorphism Message Passing Object An object is an instance of a class that contains the actual value instead of the variable. An object is a basic runtime entity. In general, an object is anything that can be recognized. All the objects around us like:- Pen, book, chair, car, TV etc. are all objects.
Class A class is a group of objects of the same type. For example:-
Mango, Guava and Apple are all fruits, and they all became members of the class Fruit. A class is a user-defined data type and a class is a set of data and functions.
Encapsulation
Encapsulation is the integration of data and functions into a single unit. In this, the variables of the class are private and they cannot be accessed directly outside the class. Encapsulation is used as a class. In a class, we can put data and methods together as a unit. Java bean is completely an encapsulated class because all the data members in it are private.
Abstraction
Abstraction means to display only the essential information of the object and to keep the background information hidden. For example- When we drive a car, we know that when we press the accelerator, the speed will increase and when we press the brake, the car will stop. But we do not know why the car stops by pressing the brake. Similarly in OOPS complex things are hidden and only essential and simple things are shown. In Java, abstract class and interface are used to achieve abstraction.
inheritance
Inheritance means ‘inheritance’. In Java, inheriting the properties and methods of another class by one class is called inheritance. The class which is derived from another class is called subclass and the class from which the subclass is derived is called super class. We also call superclass as base class and subclass we also called derived class.
Polymorphism
Polymorphism is a word derived from the Greek language in which poly means many and morphism means forms. So polymorphism means many forms. Polymorphism is a concept in which we can do the same work in two different ways. There are two types of Polymorphism in Java which are as follows:- 1:- Compile-time polymorphism (static polymorphism) 2:- Run-time polymorphism (Dynamic polymorphism)
1:- Compile time polymorphism:- Compile time polymorphism is also called method overloading or early binding. This polymorphism means that we declare methods of the same name with different signatures because we can perform different tasks with the same method name.
2:- Run-time polymorphism:- This type of polymorphism is called late binding or dynamic binding or method overriding. This polymorphism means that we declare methods of the same name with the same signature.
Message
Passing Objects communicate among themselves by sending and receiving information to each other. Objects send and receive messages in the same way as we do. A message to an object is a request for a procedure and hence a method is invoked in the receiving object.
Advantage of OOP Its benefits are as follows:-
In this, the structure of the program is very simple, which reduces the complexity. We need to write the code only once in it and we can use it again and again. It provides data redundancy. In this, we can easily maintain the code, which saves time.
object-oriented
Data hiding and abstraction are used in programming, which makes security better in it. If debugging is to be done in it, it can be done easily.