Answered step by step
Verified Expert Solution
Link Copied!

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]=

image text in transcribedimage text in transcribed 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions