2009-04-22, 10:39 AM
Your question relates to inheritance and polymorphism, and of course design patterns.
An interface is a declaration. It says what uses this interface should have. Eg a car should be drivable, ie function drive(). How is another story. Practical usage of interfaces generally lies in adaptation. It however can be used to build an abstract hierachy, and one of the biggest hierachy is the java library or C++ stl.
An abstract class is a class that cannot be instantiated (as mentioned above). Abstract classes sometimes define some functionalities, while leaves others. It can be used to define part of a function, which is common to all child classes. This is sometimes reflected via parent::function (syntax variation by languages). Abstract classes are closer to home when it comes on inheriting than interfaces. They tend to be used widely for extensible definitions.
A static attribute is an attribute that can be referred directly without instantiating the required object. It is a shared space between all instances, and updating its value affects all instances. A simple use of a static variable is to keep track of the number of objects created.
Further more, you can also have static functions. While most are just plainly forced, eg java public static void main, due to the way java works, some has deeper values. Two design patterns that relies on static functions are the factory pattern and the singleton pattern (this pattern requires static function).
An interface is a declaration. It says what uses this interface should have. Eg a car should be drivable, ie function drive(). How is another story. Practical usage of interfaces generally lies in adaptation. It however can be used to build an abstract hierachy, and one of the biggest hierachy is the java library or C++ stl.
An abstract class is a class that cannot be instantiated (as mentioned above). Abstract classes sometimes define some functionalities, while leaves others. It can be used to define part of a function, which is common to all child classes. This is sometimes reflected via parent::function (syntax variation by languages). Abstract classes are closer to home when it comes on inheriting than interfaces. They tend to be used widely for extensible definitions.
A static attribute is an attribute that can be referred directly without instantiating the required object. It is a shared space between all instances, and updating its value affects all instances. A simple use of a static variable is to keep track of the number of objects created.
Further more, you can also have static functions. While most are just plainly forced, eg java public static void main, due to the way java works, some has deeper values. Two design patterns that relies on static functions are the factory pattern and the singleton pattern (this pattern requires static function).

