For something to be abstract means to hide data. I don't understand how abstract methods hide any data from the user. An argument can be made that abstract methods require no implementation but in the grand scheme of a class hierarchy that does not hide anything from the user. Abstract methods seem to just force implementation so I do not understand why they are abstract.
-
9"For something to be abstract means to hide data"—No it doesn't. Abstract is the opposite of concrete. It means something that exists only as an idea. – khelwood Jul 31 '20 at 22:55
-
To understand why abstract classes (and interfaces, which really are just a fix for the non-existence of multi-inheritance in Java) are useful, I recommend reading up the [Interface Segregation Principle](https://en.wikipedia.org/wiki/Interface_segregation_principle). – Turing85 Jul 31 '20 at 22:57
-
Take a look at the Q/A here: https://stackoverflow.com/questions/62702925/difference-between-charsequence-interface-and-charsequence-key/62703054#62703054 This may help you understand how to use intertaces and abstract classes to make broadly reusable solutions. – ControlAltDel Jul 31 '20 at 23:14
-
1@Turing85 "*which really are just a fix for the non-existence of multi-inheritance in Java*". That is not what they are at all. – Michael Jul 31 '20 at 23:24
-
@Michael maybe not on a technical level, but on a semantical level, they are :) especially since the introduction of default methods. – Turing85 Jul 31 '20 at 23:25
4 Answers
Although abstract classes and methods can be used for data hiding, "abstract" does not mean "hide data". The Java language specification defines abstract classes and methods like this:
An abstract class is a class that is incomplete, or to be considered incomplete.
An abstract method declaration introduces the method as a member, [...], but does not provide an implementation (§8.4.7). A method that is not abstract may be referred to as a concrete method.
Abstract classes can be used for data hiding. For example, java.awt.Toolkit is an abstract class, but its concrete implementations are private. To use Toolkit, you get an instance using the static factory method getDefaultToolkit
, which returns an instance of a concrete class but you don't know which one. By providing a public abstract Toolkit class, you can use the services the class provides, but the "data" (the concrete implementation) is hidden from you.

- 108,737
- 14
- 143
- 193
For something to be abstract means to hide data.
I think your confusion comes from this (wrong) premise.
Being abstract is better understood as having no implementation. It's the opposite of concrete (i.e. with implementation).
See the abstract type article from Wikipedia:
In programming languages, an abstract type is a type in a nominative type system that cannot be instantiated directly; a type that is not abstract – which can be instantiated – is called a concrete type.

- 1,566
- 12
- 15
I think when you use the actual definition of abstract, the nomenclature of Java abstract methods makes more sense:
existing in thought or as an idea but not having a physical or concrete existence
This makes sense since Java abstract methods are method definitions without implementations.

- 3,284
- 2
- 16
- 28
The term abstract implies that something isn't tangible but more of a concept. Whereas an implementation is an actual thing that can be used. The word concrete is used to describe the latter.
Abstract classes are classes that have a mixture of zero or more implemented and zero or more non implemented methods that are used to build other classes with more or specialized functionality. So any class that subclasses an Abstract class may have:
- A set of core implemented methods inherited from the Abstract class that would not necessarily vary from one implementation to another.
- A set of method signatures (non implemented methods) specified by the Abstract class that must be implemented in subclasses and whose implementations may differ from one implementation to another depending on the subclass requirements.
- Any other additional methods that the authors of the subclass feel are required that are not specified in the Abstract class.
1 and 2 above make up the abstract class.
In the case of (1) above, those methods may be overridden if the author of the subclass deems it is necessary (unless those methods are declared final).
Finally, Abstract classes may subclass other Abstract classes employing the same philosophy above.

- 36,363
- 4
- 24
- 39