Abstract Classes - Definition
To define an abstract class, we use the abstract keyword in the class declaration. Then, we can add class members like normal. Here's an example:
Animal.java
Main.java
As you can see, abstract classes still allow for instance variables and methods, without being able to be instantiated themselves. We can count the number of animals because the Animal constructor is called by super() in both Dog and Cat.
ByteBrawl
0