Write an application class that generates 6 objects randomly from either a Car, or a Truck, or a Bicycle class. Your generated objects will be stored in a RentedVehicle array.

Write a static method in your test class that takes an array of RentedVehicles and prints the following for each element of the array:
• if the object is a car print its name and the number of seats and cost.
• if it is a Truck, print its name and capacity and cost.
• if it is a Bicycle, print its name and how many days it is rented and cost.

What is the question?

You probably know that we do not write the program for you. We will be glad to give you hints, and help you debug if you run into problems.

If you show us some of your work, we can get started from there.

To meet the requirements, you need to create three classes: Car, Truck, and Bicycle, which will represent the different types of vehicles. You also need to create an Application class that generates the objects randomly and stores them in a RentedVehicle array. Finally, you'll create a static method in the test class that prints the details of each object in the array.

Here's an example implementation:

1. Create the Car class:

```
public class Car {
private String name;
private int seats;
private double cost;

public Car(String name, int seats, double cost) {
this.name = name;
this.seats = seats;
this.cost = cost;
}

public String getName() {
return name;
}

public int getSeats() {
return seats;
}

public double getCost() {
return cost;
}
}
```

2. Create the Truck class:

```
public class Truck {
private String name;
private int capacity;
private double cost;

public Truck(String name, int capacity, double cost) {
this.name = name;
this.capacity = capacity;
this.cost = cost;
}

public String getName() {
return name;
}

public int getCapacity() {
return capacity;
}

public double getCost() {
return cost;
}
}
```

3. Create the Bicycle class:

```
public class Bicycle {
private String name;
private int rentedDays;
private double cost;

public Bicycle(String name, int rentedDays, double cost) {
this.name = name;
this.rentedDays = rentedDays;
this.cost = cost;
}

public String getName() {
return name;
}

public int getRentedDays() {
return rentedDays;
}

public double getCost() {
return cost;
}
}
```

4. Create the Application class to generate the objects randomly:

```
import java.util.Random;

public class Application {
private static final int NUM_OBJECTS = 6;

public static void main(String[] args) {
RentedVehicle[] rentedVehicles = new RentedVehicle[NUM_OBJECTS];

Random random = new Random();

for (int i = 0; i < NUM_OBJECTS; i++) {
int randomVehicleType = random.nextInt(3); // generate a random number between 0 and 2

if (randomVehicleType == 0) {
rentedVehicles[i] = generateRandomCar();
} else if (randomVehicleType == 1) {
rentedVehicles[i] = generateRandomTruck();
} else {
rentedVehicles[i] = generateRandomBicycle();
}
}

TestClass.printVehicleDetails(rentedVehicles);
}

private static Car generateRandomCar() {
String name = "Car";
int seats = new Random().nextInt(5) + 1; // generate a random number of seats between 1 and 5
double cost = new Random().nextDouble() * 100.0; // generate a random cost between 0 and 100

return new Car(name, seats, cost);
}

private static Truck generateRandomTruck() {
String name = "Truck";
int capacity = new Random().nextInt(1000) + 1; // generate a random capacity between 1 and 1000
double cost = new Random().nextDouble() * 1000.0; // generate a random cost between 0 and 1000

return new Truck(name, capacity, cost);
}

private static Bicycle generateRandomBicycle() {
String name = "Bicycle";
int rentedDays = new Random().nextInt(10) + 1; // generate a random number of rented days between 1 and 10
double cost = new Random().nextDouble() * 50.0; // generate a random cost between 0 and 50

return new Bicycle(name, rentedDays, cost);
}
}
```

5. Create the RentedVehicle interface to represent a common interface for all rented vehicles:

```
public interface RentedVehicle {
// marker interface
}
```

6. Create the TestClass and implement the static method to print the vehicle details:

```
public class TestClass {
public static void printVehicleDetails(RentedVehicle[] rentedVehicles) {
for (RentedVehicle vehicle : rentedVehicles) {
if (vehicle instanceof Car) {
Car car = (Car) vehicle;
System.out.println("Car - Name: " + car.getName() + ", Seats: " + car.getSeats() + ", Cost: " + car.getCost());
} else if (vehicle instanceof Truck) {
Truck truck = (Truck) vehicle;
System.out.println("Truck - Name: " + truck.getName() + ", Capacity: " + truck.getCapacity() + ", Cost: " + truck.getCost());
} else if (vehicle instanceof Bicycle) {
Bicycle bicycle = (Bicycle) vehicle;
System.out.println("Bicycle - Name: " + bicycle.getName() + ", Rented Days: " + bicycle.getRentedDays() + ", Cost: " + bicycle.getCost());
}
}
}
}
```

Now, when you run the Application class, it will generate 6 objects randomly (either Car, Truck, or Bicycle), store them in the RentedVehicle array, and then call the static method in the TestClass to print the details of each object in the array.