223k views
5 votes
* Declare a variable called "race" of type "Race", andinitialise its value to a new instance of the "Race" class. The"Race" constructor requires two parameters. The first shouldbe a new instance of the "Track" class, and the second shouldbe the car that you previously created.

User Lornc
by
5.2k points

1 Answer

3 votes

Answer:

Race race = new Race(track, car);

Step-by-step explanation:

Complete code fragment is as follows:

Track track = new Track();

Car car = mycar;

Race race = new Race(track,car);

Here we are declaring a variable race of the type Race which is initialized to new instance of Race class. The constructor of race takes up the following 2 arguments:

1) New Instance of Track class;

2) Previously defined reference to an object of type Car.

User Squiroid
by
4.9k points