Object-Oriented-Programming-Using-C-Characteristics-of-Object-Oriented-Programming-2
Object-Oriented-Programming-Using-C-Characteristics-of-Object-Oriented-Programming-2
Assistant Professor
Department of Computer Application
UIET, CSJM University, Kanpur
Objects
Classes
Encapsulation
Abstraction
Inheritance
Polymorphism
Objects: Object is a real world entity, In other words,
object is an entity that has state and behavior. Here,
state means data and behavior means functionality.
Object is a runtime entity, it is created at runtime.
Object is an instance of a class. All the members of
the class can be accessed through object. As the
name object-oriented implies, objects are key to
understanding object-oriented technology. There are
many examples of real-world objects: dog, television
set, bicycle etc.
Classes: A class is the building block that leads to
Object-Oriented programming. It is a user-defined data
type, which holds its own data members and member
functions, which can be accessed and used by creating
an instance of that class. A class is like a blueprint for
an object.
Encapsulation is defined as wrapping up of data and
information under a single unit. In Object-Oriented
Programming, Encapsulation is defined as binding together
the data and the functions that manipulate them.
Encapsulation also leads to data abstraction or hiding. As
using encapsulation also hides the data. In the above
example, the data of any of the section like sales, finance or
accounts are hidden from any other section.
Data abstraction is one of the most essential and important
features of object-oriented programming in C++.
Abstraction means displaying only essential information
and hiding the details. Data abstraction refers to providing
only essential information about the data to the outside
world, hiding the background details or implementation.
Using inheritance object of one class can inherit or acquire the
properties of the object of another class. Inheritance provides
reusability of code.
As such we can design a new class by acquiring the properties and
functionality of another class and in this process, we need not modify
the functionality of the parent class. We only add new functionality to
the class.
Sub Class: The class that inherits properties from another class is
called Sub class or Derived Class.
Super Class: The class whose properties are inherited by sub class is
called Base Class or Super class.
Reusability: Inheritance supports the concept of “reusability”, i.e.
when we want to create a new class and there is already a class that
includes some of the code that we want, we can derive our new class
from the existing class. By doing this, we are reusing the fields and
methods of the existing class.
Dog, Cat, Cow can be Derived Class of Animal Base
Class.
Polymorphism means many forms. Polymorphism is an important
feature of OOP and is usually implemented as operator overloading or
function overloading. Operator overloading is a process in which an
operator behaves differently in different situations. Similarly, in function
overloading, the same function behaves differently in different
situations.