Thank you very much Campbell, if possible, could you please clarify one thing about your response for me?
I'm just curious about this example:
Vehicle myCar = new Car(...);
myCar.speedUp(99);
System.out.println(myCar); // A Car travelling at 0mph.
Assuming the System.out.println method printed the speed of the object referenced by the myCar variable, why would it print 0mph?
Didn't we just change the speed with myCar.speedUp(99)?
I'm pretty sure this is because the speed of the car isn't inherited, and therefore to print the real speed that the car is moving at after changing it, we'd need to use a public getter in the vehicle class, to access the private speed variable in the vehicle class.
Also, in the example you provided, wouldn't accessing the private variable speed (not inherited) return an error at compile time?
Could you please confirm/clarify?
Thank you very much!