IS-A and HAS-A
http://stackoverflow.com/questions/9677545/what-do-has-a-and-is-a-mean?lq=1http://stackoverflow.com/questions/2218937/has-a-is-a-terminology-in-object-oriented-language
Has-a means that the Class in question 'has a' field of a type.
Is-a means that the Class extends from a superclass or implements an interface. The
Is-a means that the Class extends from a superclass or implements an interface. The
instanceof
operator would return true
if tested against a class in the this case. Example
class SteeringWheel{}
class Vehicle{}
interface transport
class Car extends Vehicle implements transport
{
SteeringWheel sWheel;
}
- A car is-a vehicle and it is for transport
- A car has-a steering wheel
No comments:
Post a Comment