posted 18 years ago
For IS-A and HAS-A relation ship, say, when you quote 'Car IS-A Vehicle', it means that Car is a type of vehicle(in java terms, its a sub class of vehicle, or it extends vehicle), while when you say 'Car HAS-A Engine', it means that the class Car has a reference to an instance of class Engine. There is no direct relation between these classes.
Hence, one can call a method on Car object to start the engine, and in turn, the car object would internally use the reference to Engine object to start the Car. This way the user doesn't have to worry about creating an instance of Engine, because Car HAS-A Engine.
Also, there might be other type of Vehicles which would need this Engine class reference. This way it avoids redundancy.
That's OOP!!!
Sid