|
While i agree with CaptainMorgan that you should attempt these things on your own, i want to explain the purpose of abstract classes because it was a hard concept for me to grasp at first.
The purpose of an abstract class is to force one to extend that class if they want to construct an object of that type. For example, say i had a class:
public abstract class BankAccount {}
If i wanted to have a BankAccount in another program, i could not simply say:
BankAccount account = new BankAccount();
Due to the fact that this class is abstract, if i want to use it, i must make a class that extends it. So for example:
public class SavingsAccount extends BankAccount {}
Now, i can say BankAccount account = new SavingsAccount(); (i'm pretty sure, not completely positive on the BankAccount portion of the line).
So, the purpose of doing this, is to make a class with general information that cannot stand alone, it must be further specified, but it has the basic info. An example that i just thought of, that would work well as an abstract class is a Weapon class for a video game. It defines general things like ammo and stuff like that, but in my main game class, i cannot define a general Weapon, i must make a more specific class that extends Weapon.
So yeah, the rest are pretty easy to understand, and if you can't understand Objects and references, i wouldn't be worrying about abstract classes and polymorphism yet, first grasp the basic concepts, and then move on to more advanced topics.
|