Abstraction in Java
Data
Abstraction is the property by virtue of which only the essential details are
displayed to the user.The trivial or the non-essentials units are not displayed
to the user. Ex: A car is viewed as a car rather than its individual
components.
Data
Abstraction may also be defined as the process of identifying only the required
characteristics of an object ignoring the irrelevant details.The properties and
behaviors of an object differentiate it from other objects of similar type and
also help in classifying/grouping the objects.
Abstract classes and Abstract
methods :
2. An abstract method is a
method that is declared without an implementation.
3. An abstract class may or
may not have all abstract methods. Some of them can be concrete methods
4. A method defined abstract
must always be redefined in the subclass,thus making overriding compulsory OR either make subclass
itself abstract.
5. Any class that contains one
or more abstract methods must also be declared with abstract keyword.
6. There can be no object of
an abstract class.That is, an abstract class can not be directly instantiated
with the new operator.
7. An abstract class can have
parametrized constructors and default constructor is always present in an
abstract class.
Advantages of
Abstraction
1. It reduces the complexity
of viewing the things.
2. Avoids code duplication and
increases reusability.
3. Helps to increase security
of an application or program as only important details are provided to the
user.

Abstracting in java

No comments:
Post a Comment