The whole idea of inheritance is to factor common logic to the highest
levels of the hierarchy. As you move up the hierarchy, some classes
become general and simply are not meant for instantiation to objects.
If you want to define a class that is simply a superclass, and can't be
instantiated, declare it abstract.
You can still use it as a parameter argument when calling methods.
For example, would we ever really instantiate a Vehicle?
Also, look at the Quarter class in the Reminder
example. We'd never really instantiate a Quarter itself, we would
have no use for it.
Of course, abstract classes can still have methods and instance fields,
that's the whole point.
To declare a class abstract, simply put abstract in the class definition.
public class Quarter would now be public abstract class Quarter.
When you have declared a class abstract, you can also declare methods within
that class abstract.
This means that the subclasses are in charge of implementing the methods.
An abstract method has no body, it just has the signature followed by a
semicolon.
Example: we could make public Date getQuiz() abstract by making
it public abstract date getQuiz();
When you make a subclass, you must override the abstract methods.
Of course, you can override any method you wish, by simply copying the
method signature and providing a method body. But with abstract methods,
you have no choice. You must implement the method.
As for access modifiers....
private will not allow subclasses to acces the data or method.
But public will let all classes access the data or method.
Thus, we can use protected to let only subclasses access the data
or method.