Quick Index
Overview


First a couple key terms:

Abstract: An idea. A concept. Describes operations (methods) that can be performed. Not a "real" thing. Not operationally usable.

Concrete: An actual thing. Reality. Yes is operationally usable.

By default, classes are concrete (usable). So far, these are the kinds of classes we have coded.

Sometimes we might have a superclass that is "abstract". This means:


Example


From our previous example we have the following class hierarchy (tree):

	Employee
		Manager
		Chef
		Waiter


Let us say that our software is modeling a restaurant where all employees are either a manager, chef or waiter. Thus no person working at this restaurant is just an "employee". Thus, "employee" is just the abstract idea and manager, chef or waiter are actual.

We will also use the term abstract for methods (as shown in the snippet below). Similar to he usage for an abstract class, an abstract method mean an idea (but without implementation/code). Concrete subclasses like Manager, Chef, etc must implement all declared abstract methods.

Here is the beginning of the Java code for this problem (note the keyword abstract in the code):

	public abstract class Employee {

		private String firstName;
		private String lastName;

		public Employee(String newFirstName, String newLastName) {
			this.firstName = newFirstName;
			this.lastName = newLastName;
		}

		public abstract String getTitle();
	}
	
	public class Manager extends Employee {

		private int teamSize;

		public Manager(String newFirstName, String newLastName) {
			super(newFirstName, newLastName);
			this.teamSize = 0;
		}

		public String getTitle() {
			return "Manager";
		}
	}