Whimusical
Whimusical

Reputation: 6629

Differences between abstract and concrete classes in inheritance, constructors, etc

We all know abstract modifier in a class makes it

In addition to that I would like to know exactly all the changes or side-effects it represents behind. One cannot ask what he/she does not now yet, but I'd like to know whether is something more to consider in terms of inheriting, constructors etc.

Aside from the two official points described, is there any difference or special behavior between an abstract class and a concrete one to be considered when extending, calling super.

Does the compiler assume it is a regular class and has the properties as such for everything other than disallowing instantiation?

Upvotes: 3

Views: 171

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726579

Abstract class is, for the most part, a design concept. It does more for the readers of your code than it does for the compiler. The compiler and JVM support required for them is minimal: it boils down to setting a "do not instantiate me" flag on the class, and checking it when compiling the code and when trying to create an instance through reflection.

Benefits to human readers of your code, on the other hand, are much bigger: they know that you designed your abstract class for inheritance, and see what extension points you made for them through abstract methods. In addition, the compiler will track for them if they have provided overrides for all abstract methods.

Upvotes: 4

Related Questions