Page 102 - Cs_withBlue_J_C11_Flipbook
P. 102
Definition
The wrapping up of data members and member methods together into a single unit is called encapsulation.
Example of encapsulation using class is as follows:
class encapsulation_example Class
{
int a;
Data Members
String n;
void input(int a1, String n1)
{
a=a1;
n=n1;
} Member Methods
void display()
{
System.out.println(a);
System.out.println(n);
}
}
Both data members and member methods are enclosed within the braces of the class encapsulation example.
4.2.2 Data Abstraction
The word – ‘abstract’ means existing in thought as an idea but does
not have a tangible existence. An object in OOP language provides an
abstraction that hides the internal implementation details. For example,
while travelling in a car as a passenger, you think only of reaching the
destination. But you never think of how the driver is driving the car by
pressing the clutch, brake, and accelerator as and when required. Similarly,
a driver, also only concerned with the steering wheel, accelerator, clutch,
and brake. But he is least interested in how they execute their functions.
In object-oriented programming, the key purpose of abstraction is to hide the details that are not required by the
users. Abstraction is like a query passed to a database that extracts the required data only leaving the rest. The main
purpose is to reduce the programming complexity. It is one of the most important concepts of OOPs.
Definition
Data abstraction is the property by which the essential features of a class are represented without knowing the
background details that how they are actually executing, i.e., non-essential units are hidden from the user.
4.2.3 Inheritance
The procedure of creating a new class with the help of a class already created Vehicle
by using its properties and functionality is said to be inheritance.
It is one of the important pillars of object-oriented programming. Human-Powered
Motor Driven
In the real world, a child inherits the properties (both materialistic and Vehicle
non-materialistic) of his parents, who have inherited them from their
parents. Car Cycle
100100 Touchpad Computer Science-XI

