> > "An abstract class is a class that is declared abstract—it may or may not > include abstract methods. Abstract classes cannot be instantiated, but they > can be subclassed. " > > For anything to work the object has to be instantiated. This means it goes > from the java file which is just basically text commands into a class file > which is the byte code the machine will use to make the object. > > Not to sure how subclassing is getting us the abstract class to become an > object.
Hi This is my first post and I'm new to all this so could well be wrong. I thought of an abstract class (which can't be instantiated) as a generic class which you wouldn't want to create an object from, so you sub-class it. The abstract class would contain common features (methods, properties, implementations etc) that would be common amongst all sub-classes. For example you might have an abstract class called Person and subclass it as something "concrete" such as Employee (extends Person) and Customer (extends Person). The abstract class would contain common and useful methods/properties such as setName, getName .... etc. The concrete classes would have some distinct business difference (e.g. employeeID and customerNumber). I originally started thinking of Man and Woman Classes but you could have a set/get Gender type method. I've seen other examples where the abstract class is Car and the concrete classes are types of Cars e.g. Ford Mondeo (I think that's a well known car- I don't drive!) So you inherit from the abstract class which contains all the common stuff and don't need to copy it all again into the sub-classes but you stop anyone from instantiating the abstract class by accident as it would be too generic. Jason --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
