Full abstraction in java without interfaces

abdul rafay :

I know that we can achieve 100% abstraction in java with interfaces and partial abstraction with abstract classes.

In interview, interviewer asked me to tell any other way to achieve 100% abstraction except interfaces. Is there any other way?

Stefan Haustein :

One could use pure abstract classes with abstract methods only (no fields, no concrete methods).

Edit: Note that starting with the addition of default methods in Java 8, interfaces are no longer necessarily 100% abstract.

In the real world, abstract classes without fields (avoiding state distributed across the hierarchy) are probably more common than pure abstract classes.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related