+ 1
Is constructor mean common method to all object create from class ??
if Vehicle is the class now we have created constructor call Vehicle() and color to red so every object's(car,bus ,van,etc) inherit from Vehicle class color is red??
1 Resposta
+ 3
If you want colors to be different for each sub-class then you would initialize colors in the sub-class constructors instead.
Similarily in the sub-class constructors you could change the Vehicles color, which by default from the Vehicle constructor would be red. Up to you really.
But yea if you left it as is, all Vehicles would be red.