Published on July 21st, 2018 | by Ryan


Object Oriented Programming (OOPs) Paradigm in Java

Object Oriented Programming is a paradigm approach which includes the concept of objects to represent the real world entities. Users can create and manipulate these objects to achieve the desired outcome from the program. Simula is considered as the first language to follow the OOPs approach. The primary objective of oops is to take advantages of real-world entities such as data encapsulation, inheritance, classes and objects, polymorphism, data abstraction etc. Core concepts of OOPs are discussed below:

1). Object and Class:

An object is a physical or logical entity which represents the state and behaviour such as a chair, pen or paper (physical), school management, banking (logical) etc. The main characteristics of the object are:

• Identity: The identity of an object is defined with a unique ID to allow java virtual machine for identification, which is not visible to the outsiders.

• Behaviour: It presents the functionality of an object. E.g., sitting, withdraw etc.

• State: It shows the value of an object. E.g., the paper is an object. Its colour is white, known as its state.

A class is a logical entity which represents the bunch of objects with similar properties. In Java, a class contains the methods, constructors, blocks, interface, nesting.

2). Encapsulation:

The process of wrapping up the code and information in a single unit is known as encapsulation. Java class can be entirely encapsulated by defining all the class member as private. Further, get and set operations are performed with the help of the getter and setter method. The main benefit of encapsulation is that it provides control over data. You can make a class fully read-only or write-only by your choice.

3). Polymorphism:

The act of performing single access in multiple ways is called as polymorphism. It is a mixture of two words: poly and morphs which means many and forms. Java supports two types of polymorphism:

• Runtime Polymorphism
• Compile time polymorphism (e.g., Overloading static method )

The polymorphism in java is achieved with the help of method overloading and method overriding.

4). Abstraction:

The process of presenting functionality by hiding implementation details to the user is known as abstraction. In simple words, abstraction only shows the essential information to the users, i.e., one which the developer wants to show. E.g., in the case of SMS, you just type, send and receive messages, you don’t know any internal working of the delivery or sending process. Abstraction allows you to focus on the primary goal rather than the hidden algorithm.

In Java, the abstraction can be achieved by two ways:

• With abstract class (achieves 0 to 100% abstraction)

• With interface (achieves 100% abstraction)

5). Inheritance:

Inheritance is a process in which an object inherits the properties and behaviours of its parent object. The primary motive of the inheritance is to create a new class which is built upon the already existing classes. Whenever a class inherits another class, the properties of the other class can be used in the base class such that it can reuse the methods and fields of the parent class.

Inheritance shows the IS-A relationship which in other words known as a parent-child relationship. Java does not support multiple inheritance.

In Java, inheritance is used for :

• Method overriding to achieve the polymorphism at the time of execution.

• Using code again.

6). Association:

Association represents the relationship between two different objects. Each object has its own life cycle and after that, it is destroyed. One object can associate with another, and the same one can also be associated with multiple objects.

Final Words to take Home:

OOPs is one of the powerful concept used by various programming languages. Among all, java is broadly used in the development of web, desktop, business and standalone applications. OOPs in java, provide a smooth and clear understanding of the process flow in the program with its incredible ability to reuse programs, reducing the development cost. If you want to achieve deep understanding of the java programming language to enhance your development skills, immediately consider Java Certification Training accessible from anywhere at anytime.

About the Author

Back to Top ↑