Question: Please help me on this! // Program one public class ArrayOfObjects { public static void main(String[] args) { Animal animals[] = new Animal[4]; animals [0]=

 Please help me on this! // Program one public class ArrayOfObjects\{ public static void main(String[] args) \{ Animal animals[] = new Animal[4]; Please help me on this!

// Program one public class ArrayOfObjects \{ public static void main(String[] args) \{ Animal animals[] = new Animal[4]; animals [0]= new Animal("Tiger", 100); animals[1] = new Animal("Lion", 80); animals[2] = new Animal("Horse", 100); animals[3] = new Animal("Monkey", 30); for(Animal animal: animals) animal.printDetails(); 3 \} class Animal \{ public String name; public int speed; public Animal(String name, int speed) \{ this. name = name; this.speed = speed; 3 public void printDetails() \{ System.out.println(name+" - "+speed); \} \} 1. What is the output of the program above? 2. Add more animals such as (Dog, 60), (Giraffa, 50), (Turtle, 10) to the program, and print the output. 3. Add variable age to the program and assume a random ages for different animals, and then print the output. Write a Java program that displays a list of cars and their owners, and prices only four cars and four owners. This is what the program should include: 1. Array of objects 2. Passing array to methods 3. For traditional loop

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!