6 Data Abstraction
6 Data Abstraction
Programming 2(JAVA)
Data Abstraction
Introduction
the internal details, for example, sending SMS where you type the
text and send the message. You don't know the internal processing
Abstraction lets you focus on what the object does instead of how
it does it.
Abstract classes and Abstract methods :
That is, sometimes we will want to create a superclass that only defines a
generalization form that will be shared by all of its subclasses, leaving it to
each subclass to fill in the details.
cont,.:
Consider a classic “shape” example, perhaps used in a computer-
aided design system or game simulation.
The base type is “shape” and each shape has a color, size, and so on.
From this, specific types of shapes are derived(inherited)-circle,
square, triangle, and so on — each of which may have additional
characteristics and behaviors.
For example, certain shapes can be flipped. Some behaviors may be
different, such as when you want to calculate the area of a shape.
The type hierarchy embodies both the similarities and differences
between the shapes.
Encapsulation vs Data Abstraction
Encapsulation is data hiding(information hiding) while Abstraction is
While encapsulation groups together data and methods that act upon
the data, data abstraction deal with exposing the interface to the
the user.
Difference
No. Class Interface
1. In class, you can instantiate In an interface, you can’t
variables and create an instantiate variables and
object. create an object.