The preceding application produces the following output:
As you can see, an engine object was created by invoking the default constructor of the Engine class without parameters and with the Java keyword new that allocated memory for the newly created object on the heap.
The second object, namely vehicle, was created with the explicitly defined constructor of the Vehicle class with two parameters. The second parameter of the constructor is an engine object that carries the horsePower property with the value set as 246, using the setHorsePower() method.
It also contains the getSpeedMph() method that can be called by any other ...