Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q4) Answer the following: [3 Marks] a) Write a declaration of a private field named library that can hold an ArrayList. The elements of the

Q4) Answer the following: [3 Marks]

a) Write a declaration of a private field named library that can hold an ArrayList. The elements of the ArrayList are of type Book.

b) Write a declaration of a private field called tracks for storing a collection of MusicTrack objects.

c) Write a method call to add the object held in the variable favoriteTrack to a collection called files.

d) Write a method call to remove the third object stored in a collection called dates.

e) Write out the header of a for-each loop to process an ArrayList called tracks. Dont worry about the loops body.

f) Write a while loop (for example, in a method called multiplesOfFive) that prints out all multiples of 5 between 10 and 95.

g) Write a declaration for an array variable people that could be used to refer to an array of Person objects.

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_2

Step: 3

blur-text-image_3

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions