The Best Technical Blog Ever


Object-Oriented Programming Concepts

This blog will introduce you to the basic concepts objects, classes, inheritance. This focuses on how these concepts relate to the real world. Object-oriented programming (OOP) is a programming paradigm that represents concepts as "objects".

What is the need of Object Oriented Proogramming?

Procedural programming languages before C++ (such as C) often focused on the way you structure a program.

  • Split the program into a set of tasks and subtasks
  • Make functions for the tasks
  • Instruct the computer to perform them in sequence

     The programmer determines the exact conditions under which a procedure takes place, how often it takes place, and when the program stops. when we use large amounts of data (or )large numbers of tasks, these programs become more complex and time consuming. After writing 10,000 to 1,00,000 lines of code in procedural language, the developers are losing their control on the code. They can't identify the errors easily. It is also difficult to modify the code. To manage this complexity, it's important to pack it into modular pieces of code. OOP allows programmers to pack away details into neat,self-contained boxes called objects.

     OOP refers to a programming methodology based on objects, instead of just functions and procedures. These objects are organized into classes, which allow individual objects to be group together. C++, Objective-C, Smalltalk, Java, C#, Perl, Python, Ruby and PHP are examples of object-oriented programming languages.

What are the advantages of OOP?

  • OOP supports and provides the modular structure for developing applications. Good definitions, abstract data types are implemented by hiding the inner details.
  • Maintaining and modifying the existing code is easier, while the existing code can be modified with minimal differences to existing objects.
  • A good framework of code library is provided by OOP, in which software components can easily be adapted and modified

Basic concepts of Object oriented programming

Data Abstraction and Encapsulation (information hiding):

  • The wrapping up of data and functions into a single unit is known as encapsulation (i.e) capturing data and keeping it safely and securely from outside interfaces. This insulation of the data from direct access by the program is called data hiding or information hiding.
  • Only those functions which wrapped in the class can access this data. These functions provide the interface between the object’s data and the program.
  • Encapsulation is the hiding of information in order to ensure that data structures and operators are used as intended and to make the usage model more obvious to the developer.
  • C++ provides the ability to define classes and functions as its primary encapsulation mechanisms.
  • Abstraction refers to the act of representing essential features without including the background details or explanations. The ability to represent data at a very conceptual level without any details. Classes use the concept of abstraction.


This is the process by which a new class (derived class) can be derived from a base class(existing class) with all features of base class and some of its own. This increases code reusability. This means that we can add additional features to an existing class without modifying it. The existing (or original) class is called the base class or super class or parent class.The new class which inherits from the base class is called the derived class or sub class or child class. The new class will have the combined features of both the classes. It supports the concept of hierarchical classification.


  • The concept of inheritence provides an important feature to the object-oriented lanuage-reusability.
  • A programmer can take an existing class and, without modifying it, and additional features and capabilities to it.
  • This is done by deriving a new class from an existing class.


The word polymorphism is derived from two Latin words poly (many) and morphos(forms). Polymorphism is the ability to exist in various forms Polymorphisms means the ability to request that the same operations be performed by a wide range of different types of things. An operation may exhibit different behaviours in different instances. The behaviour depends upon the types of data used in the operation.

Types of Polymorphism
  1. Static Polymorphism
  2. Dynamic Polymorphism


Dynamic binding:

  • Binding refers to the linking of a procedure call to the code to be executed in response to the call.
  • Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run-time.
  • It is associated with polymorphism and inheritance.

Message passing :

An object oriented program consists of a set of objects that communicate with each other. Objects communicates through invoking methods and sending data to them. This feature of sending and receiving information among objects through function parameters is known as Message Passing. The process of programming in an object oriented language involves the following basic steps:

  1. Creating classes that define objects and their behaviour
  2. Creating objects from class definitions
  3. Establishing communication among objects

Objects communicate with one another by sending and receiving information much the same way as people pass messages to one another. A message for an object is a request for execution of a procedure, and therefore will invoke a function (procedure) in the receiving object that generates the desired result. Message passing involves specifying the name of the object, the name of the function (message) and the information to be sent.

Key features of the Object Oriented programming

  • Emphasis on data rather than procedure
  • Data Structures are designed to characterize objects
  • Programs are divided into small entities known as objects
  • In data structures, functions that operate on data of an object are tied together
  • Data is hidden and cannot be accessed by external functions
  • Objects communicate with each other through functions (message passing)
  • New data and functions can be easily added whenever needed
  • Program design follows bottom up approach

What is an Object?

Object is the basic unit of object-oriented programming. An object can be considered a "thing" that can perform a set of activities. The set of activities that the object performs defines the object's behavior. Objects are identified by its unique name. An object represents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data. Each object has a structure similar to other objects in the class, but can be assigned individual characteristics. In general, Real-world objects share two characteristics: They all have state and behaviour.

For example, Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail). Similarly, Software objects too consist of state and related behavior. An object stores its state in fields (variables/data members) and exposes its behavior through methods (member functions).


What is a Class?

A class is a blueprint or prototype from which objects are created. Objects with similar properties and methods are grouped together to form a Class. Characteristics of an object are represented in a class as Properties. The actions that can be performed by objects become functions of the class and is referred to as Methods. Class is composed of three things name, attributes, and operations.

For example consider we have a Class of Cars under which maruti, mercedes, toyota, hyundai, tata, nano and Alto represents individual Objects. In this context each Car Object will have its own, Model, Year of Manufacture, Colour, Top Speed, Engine Power etc., which form Properties of the Car class and the associated actions i.e., object functions like Start, Move, Stop form the Methods of Car Class. No memory is allocated when a class is created. Memory is allocated only when an object is created, i.e., when an instance of a class is created.


This diagram shows the student class with data members such as name, grade and member functions getName() & printGrade().

Keypoints to remember in java

1. Java is a high level, robust, secured , platform independent and object oriented programming.... more info

Back to Basics:- Java Syntax

In this session, you are going to refresh some basic set of rules(java syntax), defining how a ... more info

Total Visits
Traffic feed status