Question: Problem Set 5 1. Write a declaration of a Java variable named library that can hold an ArrayList. The elements in the list are of

Problem Set 5 1. Write a declaration of a Java variable named library that can hold an ArrayList. The elements in the list are of type Book. 2. Write a declaration of a Java variable named cs101 that can hold an ArrayList of type Student. 3. Write a declaration of a Java variable named tracks for holding a collection of MusicTrack objects. 4. Write assignments to the three variables you created in questions 1 to 3 to create the appropriate ArrayList objects. 5. What is the index of the first element in an ArrayList? 6. What is the index of the last element in an ArrayList of 12 items? 7. Write a Java statement that will add the String the end to the end of an ArrayList of type String named myStrings. 8. Write a Java statement that will retrieve the 5th element in an ArrayList of type Book named bookCollection and assigns it to the Book object named theBook. 9. Write a Java statement that will remove 2nd element in an ArrayList of type Book named bookCollection. 10. What will be returned by the Java statement myStrings.size(); if myStrings is an ArrayList of Strings that currently holds 7 elements. 11. Write a Java statement that will remove the next to last element in an ArrayList of type Book named bookCollection. 12. Write a Java while loop that will add all the multiples of 3 from 9 through 3000 inclusive. For questions 13 to 17, use the skeletal class definitions below: public class BankAccount { private double balance; private String accountNum; public double getBalance(); public String getAccountNum(); } public class AccountManager { private ArrayList accountList; } 13. Write the constructor for the AccountManager class that initializes accountList to an empty ArrayList. 14. Write a method for the accountManager class called addAccount that will add a new BankAccount object to accountList. 15. Write a method for the accountManager class called removeAccount that will remove a BankAccount object that is specified by its index from accountList. 16. Write a method for the accountManager class called listAccounts that will print all the BankAccount objects (balance and account number for each account, one account per line) in accountList. 17. Write a method for the accountManager class called findMax that will print the account number and balance for the BankAccount object with the highest balance in accountList.

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!