+ 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??

8th Jun 2017, 4:12 AM
Bawantha Rajapaksha
Bawantha Rajapaksha - avatar
1 Answer
+ 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.
8th Jun 2017, 4:51 AM
Rrestoring faith
Rrestoring faith - avatar