+ 3
What is the use of abstract classes in java ?
I know that it is to hide complex data and enable only the simplest data but how does it work?
3 Antworten
+ 3
An abstract class cannot be instantiated (but it has a constructor which is called when instantiating a children class ie. a concrete class).
it is used as some kind of interface which would be already partly implemented or not (before java8). you can use an abstract class to define backbone code which is common for all the children/concrete classes and yet not directly instantiable.
I have never seen any abstract classes in company code until now. it seems mostly interfaces are used, its more readable than extending an abstract class.
+ 1
Thank u @Ronald sterkendries ...that was helpful
- 1
הנגכ