






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Kristen's office hours are canceled tomorrow
Remember classes are templates that we use to create objects We can also use classes as templates for other classes (this is inheritance) Sometimes when making these templates, we don't know what to fill in, but we want every class to have that method. (See: BadCards, BadBirthday, BadHoliday.java)
It is possible to create templates even when we don't know how some methods are going to work yet To do this we use an abstract class (shown below): To create the abstract class, you simply put the word abstract in your class declaration
Abstract methods must be inside an abstract class Since children have to override these methods, they cannot be private (non-inherited) Error!
It is illegal to try and create an instance of an abstract class, since it is not fully defined You can however, use it as a type to store its children In fact, abstract classes are only really useful as a parent to other classes
A good example of where abstract classes make sense is biological classification All animals are broken down into: Kingdoms, Phylum, Class, Order, Family, Genus and Species Higher ranks are more general, lower ranks are more specific
A good example of where abstract classes make sense is biological classification All animals are broken down into: Kingdoms, Phylum, Class, Order, Family, Genus and Species Abstract classes make sense, because no real animal exists until the “Species” point (until then it is categorization)