Skip to content

Commit 9abaf70

Browse files
authored
Update README.md
1 parent 83fe290 commit 9abaf70

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,24 @@ Encapsulation is the mechanism that binds together code and the data it manipula
306306

307307
4.**Testing code:** Encapsulated code is easy to test for unit testing.
308308

309+
# ABSTRACTION:
310+
311+
Data Abstraction is 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.
312+
313+
Consider a real-life example of a man driving a car. The man only knows that pressing the accelerators will increase the speed of car or applying brakes will stop the car but he does not know about how on pressing the accelerator the speed is actually increasing, he does not know about the inner mechanism of the car or the implementation of accelerator, brakes etc in the car. This is what abstraction is.
314+
In java, abstraction is achieved by interfaces and abstract classes. We can achieve 100% abstraction using interfaces.
315+
316+
317+
An abstract class is a class that is declared with abstract keyword.
318+
An abstract method is a method that is declared without an implementation.
319+
An abstract class may or may not have all abstract methods. Some of them can be concrete methods
320+
A method defined abstract must always be redefined in the subclass,thus making overriding compulsory OR either make subclass itself abstract.
321+
Any class that contains one or more abstract methods must also be declared with abstract keyword.
322+
There can be no object of an abstract class.That is, an abstract class can not be directly instantiated with the new operator.
323+
An abstract class can have parametrized constructors and default constructor is always present in an abstract class.
324+
325+
Code:**[Abstraction.java](https://github.com/disha2sinha/Object-Oriented-Programming-in-Java/blob/master/Abstraction.java)** :Abstraction implemented using Abstract class and abstract methods.
326+
309327
# PACKAGES:
310328

311329
A package is a container within which we can store multiple classes,subpackages and interfaces.A package is a container of a group of related classes where some of the classes are accessible are exposed and others are kept for internal purpose.

0 commit comments

Comments
 (0)