Page 99 - ComputerScience_Class_11
P. 99
Definition
The wrapping up of data members and member methods together into a single unit is called encapsulation.
An example of encapsulation using a 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 an 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 is 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 Vehicle
The procedure of creating a new class with the help of a class already created
by using its properties and functionality is said to be inheritance.
It is one of the important pillars of object-oriented programming. Motor Driven Human-Powered
Vehicle
In the real world, a child inherits the properties (both materialistic and
non-materialistic) of his parents, who have inherited them from their Car Cycle
parents.
Introduction to Object-Oriented Programming Using Java 97

