Currently in my Java class we are working with semi-advanced types of classes, of which I can't seem to understand. I was wondering if someone could point out to me a resource for the following items, preferably with analogy-like explanations. Any help that can be provided that doesn't include references, is welcome too.
Now, some quick examples of your topics. abstract class - a class declared to be abstract Note that such a class cannot be direction instantiated with the new operator.
abstract method - a method without an implementation Such a method can only be declared in an abstract class or in an interface. Non-abstract subclasses or classes that implement the interface must provide an implementation of the declared abstract method.
Note that the method in the interface did not need to be labeled abstract. All methods declared in an interface are implicitly abstract. Also note that all methods declared in an interface are implicitly public, even if not explicitly declared to be so. As such, the implementing class must also declare the method to be public. class (static) method - a method in a class defined to belong to the class, and not to instances of the class
Note that it wasn't necessary to create an instance of Foo in order to call the static method. class (static) variable - much like a static method, this is a variable defined in a class to belong to the class, not to instances of the class
Note that it wasn't necessary to create an instance of the Foo class in order to access and use the static variable i. concrete classes - A class that is not abstract.
final method - such a method cannot be overridden in a subclass
inheritance - a mechanism whereby one class definition can extend another, where the extending (sub)class inherits some (or all) of the behaviors (methods) defined in the extended (base) class This is a fundamental concept of object-oriented programming.
Note that even though the Foo class does not define a method named method, the foo instance has access to the one defined in the parent class Bar. interface - a mechanism for categorizing/marking implementing classes with another data type Note that since only single inheritance is allowed in Java (that means a class can be defined to extend at most one other class), this implementing of interfaces is especially useful for developing well designed, polymorphic code. Above is an example using an interface. For a greater understanding of the role of interfaces and just what polymorphism is, spend a few minutes reading the "How my Dog learned Polymorphism" story of the JavaRanch Campfire Stories. overriding - where a subclass declares a (non-static, non-private) method with the same signature as one in a parent class.
postcondition - something concerning the state of a system (or object) that may have changed after a method is invoked In other words, something that is true after a method is called - something concerning an object's state, that is. precondition - something that must be true before a method is called This might be something about the state/value of a method parameter, or something about the state of the object that has the method being called. Making any sense?