Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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]; 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 loopStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started