An abstraction is a generalization, something that describes a thing or a related group of things theoretically. To stay with the food analogy, consider the concept of a
fruit. As Darin's example stated, you don't eat a fruit, per se, you eat a type of fruit, such as an apple or banana. So what defines a fruit in theoretical terms? Well, you can peel a fruit before you eat it, so let's go with that. So you have the following
abstract class called Fruit:
It represent a
general idea of a thing that is a fruit. Since you can't eat a general idea, we have to refine the general idea to something specific or
concrete, so we create two new classes, Apple and Banana:
The important concept here is that since an Apple and a Banana are both "peelable"(since they inherit the peel() method), but exactly how you peel them is different, you must give each of the classes
a concrete implementation of the abstract peel method. In other words, you take the generality of peeling a fruit and tell each class how to do it in a way that is appropriate for the type of fruit, be it an apple or a banana.
Does that make sense?
As for static, a static variable or method belongs to the class itself, not specific instances of the class. The point to see here is the distinction between a class and an instance of that class, usually called and object. A class is a blueprint for creating objects, but sometimes it makes a lot of sense to associate a variable or a method with the blueprint of the object instead of the object itself. The big advantage of this is that you do no need to create a specific instance of a class to access a static variable or method. If you know the class, you can access the static parts just by the class name, i.e. It would be a hassle, and inefficient, to always have to create an instance of a System object to be able to print to the console, so Sun gave the System class a static output stream called "out" that you access by calling:
without having to construct a System object in each class that needs it.
HTH,
E
[ June 18, 2004: Message edited by: Eric Fletcher ]