October 2017
Beginner
318 pages
7h 26m
English
We may sometimes see methods that exist only to be overloaded by subclasses. These methods don't do anything, and we can tag them with the abstract keyword, that is, public abstract void Print(), in the superclass (Literature.java). Of course, if a class has methods declared abstract, it's probably a good sign that an instance of such a class should never be explicitly created. If our Literature class's Print method is abstract, we should never declare objects that are only Literature. We should only use objects that are one of the subclasses of Literature. If we're going to go down this route, we should declare Literature to be an abstract class as well:
package inheritance;public abstract class Literature {
If we did ...
Read now
Unlock full access