Question: 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

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!