OOPs is a design philosophy. It stands for Object Oriented Programming system.
Everything in OOPs is grouped as “objects“. Hence, OOPs provide the reusability by means of four main object-oriented programming concepts.
In order to clearly understand the OOPs model, let’s take your “Eye” as an example. This “Eye” is a class. Your body has two objects of the type “Eye”, named “left Eye” and “right Eye”.
Their main functions are controlled or managed by a set of electrical signals sent through your Mind (through an interface). So the mind is an interface that your body uses to interact with your Eyes. The Eye is a well-architected class. The Eye is being reused to create the left Eye and the right Eye by slightly changing the properties of it.
Object In Java
An object can be considered a “thing” that can perform a set of activities. These activities that the object performs defines the object’s behavior.
For example, the Eye(object) can see something. An object has its own state and behavior.
In pure OOPs terms, an object is an instance of a class.
Class in Java:
A class is simply a representation of a type of object. It is the blueprint or plan or template, that describes the details of an object. You may also say “Class is the collection of objects that connect object logically“. Also, A class is the blueprint from which the individual objects are created.
The class is composed of three things: a name, attributes, and operations.
A software application may consist of many classes. When you have many classes, it needs to be managed. In order to manage the classes of a software system, and to reduce the complexity, OOPs used four main concepts named
Products from Amazon.in
Price: Check on Amazon
Price: Check on Amazon
Price: INR 15,390.00
These concepts are the four pillars of OOPs, they are called four main Object Oriented Programming (OOP) Concepts.
Binding code and data together into a single unit are known as encapsulation. In OOPs the encapsulation is mainly achieved by creating classes, the classes expose public methods and properties. A class is kind of a container which encapsulates a set of methods, attribute, and properties to provide its indented functionalities to other classes.
In that sense, encapsulation allows a class to change its internal implementation without affecting the overall functioning of the system. That the basic idea of encapsulation is to hide, how a class does its business while allowing other classes to make requests of it.
Abstraction is hiding the project internal implementation and showing the functionality only. The importance of abstraction is derived from its ability to hide irrelevant details and from the end user. Abstraction is essential in the construction of programs. Abstraction defines what an object is or does rather than how it is represented or how it works. Thus, it is the primary means of managing complexity in large programs.
The ability of a new class to be created, from an existing class by extending it, is called inheritance. The most important relationships among objects in the real world are specialization, which can be described as the “is-a” relationship. When we say that a BMW is a Car, we mean that BMW is a specialized kind of Car. It has all the characteristics of any Car.
An Audi is also a Car. As such, we expect it to share certain characteristics with the BMW that are in Car but to differ in those characteristics that are specialized in Audi.
In OOPs, the specialization relationship is implemented using the OOPs concept called inheritance. This is the most common and widely accepted way of implement this relationship.
Polymorphism is a generic term that means ‘many shapes’. More precisely Polymorphisms means one task is performed by different ways.
In OOPS, the polymorphisms are achieved by using many different techniques named method overloading, operator overloading, and method overriding.
Selenium Testing Video Tutorial: