OBJECT ORIENTED PROGRAMMING - JAVA

Introduction

OBJECT ORIENTED PROGRAMMING (OOP) Object-Oriented Programming (OOP) is an approach to standardize the programs by creating a partitioned memory area for both data and function. It has been developed to increase the programmer's productivity and also to overcome the traditional approach of programming.



Define: An Object-Oriented Programming (OOP) is a modular approach, which allows the data to be applied within the stipulated program area. It also provides the reusability feature to develop productive logic, which means to give more emphasis on data.


FEATURES OF OBJECT-ORIENTED PROGRAMMING (OOP)

  • It gives stress on the data items rather than functions.
  • It makes the complete program/problem simpler by dividing it into several objects.
  • The objects can be used as a bridge to have data flow from one function to another.
  • You can easily modify the data without any change in the function.

 

BASIC ELEMENTS OF OOP (PRINCIPLES OF OOP)

The basic elements of Object-Oriented Programming are:

Objects

Classes

Data Abstraction

Data Hiding

Inheritance

Polymorphism

Encapsulation

Dynamic Binding

 

Define: The object is a unique entity, which contains data and functions (characteristics and behavior) together in an Object-Oriented Programming (OOP) Language.

Some real-world object:

V8 engine,(Drift wheel) Kumho Ecsta PS31, Dual-clutch, and many more could be term as a real-world object

  • An the object contains member variables to hold data values.
  • The data values of an object can be defined as the state.
  • The the behavior of an object can be implemented through member functions.

 

Define: A class is simply a representation of the type of objects. It is the blueprint plan template that describes the details of an object. A class is a blueprint from which the individual objects are created. Class is composed of three things viz. a name, attributes, and operations 

Some real-world class of above object:

Car is class of all real-world objects listed above. Other are airplane (boing, airbus, private are their object ), house(Condominium, Apartment, Townhome, Bungalow are their object), school(government, private, smart are their object), etc

 Creating an object in class

  • Declaration: It uses class as a data type along with an object.
  • Instantiation: The 'new' keyword is used for allocating an object in the dynamic memory.
  • Initialization: It is used for calling a constructor to initialize the attributes of an object.

 

Syntax of creating an object of a class:

<Class Name><Object Name> = new <Class Name> ();

 

Difference between class and object:


The object is an instance of a class.

Class is a blueprint or template from which objects are created.

The object is a real-world entity such as a pen, laptop, mobile, bed, keyboard, mouse, chair, etc.

Class is a group of similar objects.

An object is a physical entity.

The class is a logical entity.

The object is created through a new keyword mainly

e.g.
Student s1=new Student();

Class is declared using the class keyword 

e.g.
class Student{}

The object is created many times as per requirement.

The class is declared once.

Object allocates memory when it is created.

Class doesn't allocate memory when it is created.

There are many ways to create an object in java such as new keyword, newInstance() method, clone() method, factory method, and deserialization.

There is only one way to define the class in java using the class keyword.


Define: Wrapping of data and functions of a class together so that they can be applied as a unit to perform any operation is termed as Encapsulation.

Some real-world class of above object:

The acceleration is manual and assessable to the user but when it some to speedometer it is not controlled by the user directly or we can say it is not assessable. Or more specifically coordination of torque and Gare shift.

Class:


 Blue: access allowed

            (acceleration)

 Gray: assess denied

            (speedometer)

 


Define: Abstraction refers to an act of representing essential features without including background details.

Some real-world class of the above object:

The transmission of Gare in interior version is unknown to the user whereas a user know to change Gare by paddle shift or manual shift

  • Steering: It is an arrangement to turn the front wheels, which is positioned in front of the driver and allowing him to turn as per his needs.
  • Accelerator: It helps the driver to speed up or speed down.
  • Clutch: It is used to change the gears. It is also used at the time of applying
  • Break: It allows the driver to stop the car.
  • Gears: They are used to increase or decrease the transmission ratio of the car depending upon the road condition and speed.

 

Define: Inheritance is the process in which objects of one the class can like and share some common properties of the objects with another class.

Some real-world class of above object:

Car has Mercedes BMW Mustang and extra…

New tech WORD

Reusability: The process of adding some additional features to a class without modifying its contents. This process can easily be attained if a class inherits another class which means the new class acquires some features from the existing class.

 

Define: Polymorphism is the process of using a function for more than one purpose. It allows the use of the different internal structures of the object by keeping the same external interface.

Some real-world class of above object:

Either Mercedes, BMW, Mustang, or another car require steering and here steering is termed as the same function which could be used in one or many functions


Define: Dynamic binding is the process that links the function call with function signature at run-time i.e., during the execution of a program.

Some real-world example

Twin-turbo, supercharge, And others could be termed as DYNAMIC BINDING on main CLASS car for better function.  

 

Benefits of Object-Oriented Programming (OOP)

There are many benefits of OOP to the programmers as well as the users. Some benefits of OOP areas listed below:

  • You can extend the use of existing classes through inheritance.
  • Using the concept data hiding," you can generate a secured program.
  • Multiple instances of an object can be generated to co-exist without interference.
  • You can create different modules in your project through objects.
  • It is highly beneficial for solving complex problems.
  • It is easy to modify and maintain software complexity.

~Aaditya Rasala


Comments

Post a Comment

Popular Posts