Object oriented Programming Concepts

object oriented programming
object oriented programming

We talked about C language in the previous article. Here we’re going to talk about object orientating programming. Object orientating programming is thought as OOP and it’s employed in a contemporary artificial language like Java. In Java, object-oriented programming ideas are the main theme behind java’s object-oriented programming and it’s such a model that operates these objects to induce results is that the target of object-oriented programming. “object” are often a mix of variables, functions, and knowledge structures. whereas planning an application distinctive understanding of OOPs ideas will facilitate in higher cognitive process that however technologist ought to style an application and what language ought to be employed in that application. It conjointly related to several ideas, like inheritance, abstraction, information binding and polymorphism, etc.

Object orientating programming which brings information and its behaviour all at once during a single location which makes it easier to know however a program works, to know the idea however they really work grasping is that the necessary key for that. For the creation of operating strategies and variables with the assistance of java object-oriented programming ideas and most fascinating half is once this creation of strategies and variables, users are able to re-use all or a part of them while not compromising the protection.

To increase the liability and maintainability of programs is that the primary purpose of object-oriented programming. Bind along the information and also performs that operates them so no alternative part of the code will access to the present data except that function which is incredibly basic object of object-oriented programming.

Programmer deals with information or playing specific operations on the information in program, having information and also the performance of some sure operation on it information could be a basic characteristic in any software system program. Java, C#, PHP, Python, C++, etc. are the foremost widespread object oriented programming languages. Simula is that the initial object-oriented artificial language and such a programming paradigm wherever everything is portrayed as an object is actually a object-oriented artificial language.


Aggregation and its composition each are the thanks to win association. Aggregation represents the connection wherever one object contains alternative objects as a district and It represents the weak relationship between objects. whereas composition of relationship one object contains alternative objects as a district of its state, there’s a robust relationship between the containing object and also the dependent object, and it’s the state wherever containing objects don’t have an freelance existence. If you delete the parent object, and all the kid objects are deleted mechanically.

Advantage of OOPs over Procedure-oriented programming language:

1) OOPs makes development and its maintenance easier and during a procedure-oriented artificial language, it’s difficult to manage if code grows as project size will increase.

2) OOPs provides information concealing, whereas, during a procedure-oriented artificial language, international information are often accessed from anyplace.

3) OOPs provides the flexibility to simulate real-world event way more effectively. we are able to give the answer of real word drawback if we tend to are victimisation the Object-Oriented artificial language.

Difference between an object-oriented artificial language and object-based programming language:

Object-based artificial language follows all the options of OOPs except Inheritance. JavaScript and VBScript are samples of object-based programming languages.

Characteristics of Objects:



Message passing


It’s a method wherever a technologist shows solely relevant data from the user and conceal all alternative data that is not sensible. Abstraction of knowledge perhaps outlined because the method of showing solely the specified characteristics/units and completely ignoring the secondary details to its user. Abstraction of the information could be a property by that solely the relevant details are flaunted to its user the digressive units aren’t flaunted to its user. For example: a motorbike is viewed as a motorbike instead of its individual parts. If objects having an analogous sort with alternative object then object properties will differentiate it from others.

For instance, whereas driving solely driver is aware of that pressing the accelerations can increase the speed of automotive however he doesn’t grasp the inner method of the implementation of the accelerator, this is often all what abstraction is. In java, abstraction is achieved by abstract categories and interface and 100% abstraction is often achieved by victimisation interfaces.


Encapsulation means that binding object and behaviour along. For the creation of sophistication, the technologist is doing the encapsulation methodology. Encapsulation could be a protect that forestalls the information from being accessed by the code outside this protect.

Encapsulation could be a mechanism to wrapping of information beneath one unit, it manipulates the information, that conjointly binds along code. The data of a category is hidden from the other category and may be accessed solely through any member perform of own class within which they’re declared and as in encapsulation, the information during a category is hidden from alternative categories, thus it’s conjointly called data-hiding. Encapsulation are often achieved by declaring variables within the category as non-public and to line and find the values of variables for the writing public strategies at school.

Message passing:

By causation and receiving data to every alternative objects communicate with each other. It’s an application that contains several objects as a result of solely single objects by itself might not be helpful. Through invoking methodology on it object, one object interacts with the opposite object. Message that is passing simply involves specifying the name of the thing, perform and data to be sent.

Abstract Class and methods in OOPs Concepts:

Abstract method:

A method that is not defined just declared and only the method signatures no body. Declared using the abstract keyword and Used to put some compulsion on class who inherits the class has abstract methods. The class that inherits must provide the implementation of all the abstract methods of parent class else declare the subclass as abstract.

These cannot be abstract:

  • Constructors
  • Static methods
  • Private methods
  • Methods that are declared “final”

Abstract Class:

An abstract class highlights the methods but not necessarily implements all the methods.

Class in OOPs Concepts:

A class in object oriented programming is considered as a blueprint using which programmer can create as many objects as you like. For example, here we’ve a category website that has two data members and it also referred to as fields, instance variables and object states. This is just a blueprint, it doesn’t represent any website, however using this we will create website objects or instances that represents the websites. We have created two objects, while creating objects we provided separate properties to the objects using constructor.

A class may be a user defined prototype from which objects are created. It represents the group of properties that are common to all objects of one type.

Modifiers: can be public or has default access.

Class name: name should begin with an initial letter.

Superclass: name of the class’s parent, a class can only extend one parent.

Interfaces: comma-separated list of interfaces implemented by class.

Body: body surrounded the class by braces {}.

Important terminology:

Super Class: the category whose features are inherited is understood as superclass or a base class or a parent class.

Sub Class: The class that inherits the other class is known as subclass or a derived class, extended class, or child class. The subclass can add its own fields and methods additionally to the superclass fields and methods.

Reusability: Inheritance supports the concept of “reusability”, i.e. when we would like to make a replacement class and there’s already a category that has a number of the code that we want, we will derive our new class from the existing class. By doing this, we are reusing the fields and methods of the prevailing class.


Polymorphism may be a object oriented programming feature that permits us to perform one action in several ways. For example, let’s imagine we’ve a category animal that features a method animal sound, we cannot give implementation to the present method as we don’t know which animal class would extend animal class.

and in a result we will have the common action for all subclasses animal sound but there have been alternative ways to try to to an equivalent action. This is an ideal example of polymorphism feature that permits us to perform one action in several ways.

Polymorphism refers to the power of OOPs programming languages to differentiate between entities with an equivalent name efficiently. This is done by Java with the assistance of the signature and declaration of those entities.

Types of Polymorphism:

1) Static Polymorphism

2) Method Overloading

3) Dynamic Polymorphism

1. Static Polymorphism:

Polymorphism that’s resolved during compiler time is understood as static polymorphism. Method overloading are often considered as static polymorphism example.

2. Method Overloading:

This enables us to possess quite one methods with same name during a class that differs in signature.

3. Dynamic Polymorphism:

It is also known as Dynamic Method Dispatch. Dynamic polymorphism may be a process during which a call to an overridden method is resolved at runtime rather, that’s why it’s called runtime polymorphism.

Abstract Class and methods in OOPs Concepts:

Abstract method:

1) a way that’s declared but not defined. Only method signature no body.

2) Declared using the abstract keyword.

3) Example : abstract public void play Instrument();

5) want to put some quite compulsion on the category who inherits the category has abstract methods. The class that inherits must provide the implementation of all the abstract methods of parent class else declare the subclass as abstract.

6) These cannot be abstract;

  • Constructors
  • Static methods
  • Private methods

7) Methods that are declared “final”.

Abstract Class:

An abstract class outlines the methods but not necessarily implements all the methods.

Example of Abstract class and Methods:

An abstract class animal that has an abstract method animal sound, since the animal sound differs from one animal to a different, there’s no point in giving the implementation to the present method as every child class must override this method to offer its own implementation details. That’s why we made it abstract.

Now each animal must have a sound, by making this method abstract we made it compulsory to the kid class to offer implementation details to the present method. This way we ensures that each animal features a sound.

Best Practices for OOP Concepts in Java:

Aim of OOP concepts in Java is to save time, ease of use and without compromising security and the best practices are all oriented toward advancing that main goal.

Dont Repeat Yourself: this is often the core concept in Java. You should never have two blocks of identical code in two different places. Instead, have one method you employ for various applications.

If you expect your Java code to vary within the future, encapsulate it by making all variables and methods private at the outset. As the code changes, increase access to “protected” as required but not too public.

Single Responsibility: Another best practice for OOP concepts in Java is that the Single Responsibility Principle. Simply put, a category should have just one functionality. That way, it are often called and/or extended on its own when new uses arise for it, without causing coupling between different functionalities.

Open Closed Design: Make all methods and classes Closed for modification but Open for an extension. That way, tried and tested code can remain static but are often modified to perform new tasks as required .

You can also learn the C language with our articles as well.


I am a Software Engineer with ample experience in making games, websites, mobile apps and augmented reality solutions.

Pin It on Pinterest