•
It is a user-defined data type, which holds
its own instance variables and instance methods, which can be accessed and used
by creating an instance of that class.
•
A class is like a blueprint for an object.
For Example:
•
Consider the Class of Cars.
•
There may be many cars with different names
and brands but all of them will share some common properties like all of them
will have 4 wheels, Speed Limit, Mileage range, etc.
•
In the above example of class Car, the
data member will be speed limit, mileage, etc, and member functions can apply
brakes, increase speed, etc.
Object
•
An Object is an instance of a Class.
•
When a class is defined, no memory is
allocated but when an object is created memory is allocated.
Encapsulation
•
Encapsulation is defined as wrapping up data and information under a single unit.
•
Using encapsulation also hides
the data. It is called data hiding
Data Abstraction
•
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.
•
Consider a real-life example of a man
driving a car.
⮚
The man only knows that pressing the
accelerator will increase the speed of the car
⮚
but he does not know about how pressing the accelerator the speed is actually increasing,
⮚
He does not know about the inner
mechanism of the car or the implementation of accelerators, brakes, etc in the
car.
⮚
This is what abstraction is.
Polymorphism
•
The word polymorphism means having many forms.
•
In simple words, we can define polymorphism as
the ability of a message to be displayed in more than one form.
Inheritance
•
It is the process by which objects of
one class acquire the properties of objects of another class
Base Class or Superclass:
The class whose
properties are inherited by a subclass is called Base Class.
Derived Class or subclass:
The class that inherits properties from another class is called Derived Class.
•
The code to be executed in response to
function calls is decided at runtime.
Message Passing
•
Objects communicate with one another by
sending and receiving information to each other.
0 Comments