G
G
go2goj2019-11-30 20:35:57
Java
go2goj, 2019-11-30 20:35:57

What is abstraction (OOP principle) in Java?

If encapsulation in Java is represented by access modifiers, what is abstraction represented by?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2019-12-01
@go2goj

Abstraction is a key phenomenon in OOP
The class itself is already an abstraction of something, when I create the Product class, it is an abstraction of some objects of my system, which distinguishes them from the entire internal world of the system at least by the name (and then by the interface and behavior described in class).
But the key to abstraction is the interface, it is in every class (public and private), but since the class already has a description of the behavior and the object, it is difficult to separate such an abstraction, so we came up with the interface design - an abstraction in its purest form. We simply pass an abstract convention and everyone who knows how to work with it works with those objects that implement this interface. This is polymorphism.
We can also abstract some functionality from binding to a specific type. And create a functional over an abstract (generic) type - generics (parametric polymorphism).
Inheritance, encapsulation, and polymorphism are key ways to create abstraction.

  • Polymorphism - we create either an interface or an abstract class, which will outline the boundaries of abstraction and already in specific implementations we "materialize" the abstraction. Or we create a certain class that works with any type, but strictly specified when creating an object (parametric polymorphism)
  • Inheritance - we take out similar behavior for a number of classes into abstraction (parent class, abstract class)
  • Encapsulation - we clean up the abstraction, giving out only the public interface (abstraction boundaries), we hide everything else (not related to our abstraction)

@
@atambalasi, 2019-12-02
_

See more about encapsulation here .
Abstraction is a distraction in the process of cognition from non-essential aspects, properties, relations of an object (object or phenomenon) in order to highlight their essential, regular features. The result of abstraction is abstract concepts, for example: color, curvature, beauty, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question