Exercise 4.4 Write a declaration of a private field named library that can hold an ArrayList....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Exercise 4.4 Write a declaration of a private field named library that can hold an ArrayList. The elements of the ArrayList are of type Book. Exercise 4.7 Write assignments to the library, cs101, and track variables (which you defined in the previous three exercises) to create the appropriate ArrayList objects. Write them once using diamond notation and once without diamond notation, specifying the full type. Exercise 4.8 If a collection stores 10 objects, what value would be returned from a call to its size method? Exercise 4.11 Write a method call to add the object held in the variable favoriteTrack to a collection called files. Exercise 4.12 Write a method call to remove the third object stored in a collection called dates. Exercise 4.13 Suppose that an object is stored at index 6 in a collection. What will be its index after the objects at index 0 and index 9 are removed? Exercise 4.14 Add a method called checkIndex to the MusicOrganizer class. It takes a single integer parameter and checks whether it is a valid index for the current state of the collection. To be valid, the parameter must lie in the range O to size()-1. If the parameter is not valid, then it should print an error message saying what the valid range is. If the index is valid, then it prints nothing. Test your method on the object bench with both valid and invalid parameters. Does your method still work when you check an index if the collection is empty? Exercise 4.30 Write a while loop (for example, in a method called multiplesOfFive) that prints out all multiples of 5 between 10 and 95. Exercise 4.47 The makeABid method includes the following two statements: Bid bid = new Bid(bidder, value); boolean successful = selected Lot.bidFor (bid); The bid variable is only used here as a placeholder for the newly created Bid object before it is passed immediately to the lot's bidFor method. Rewrite these statements to eliminate the bid variable by using an anonymous object as seen in the enterLot method. Exercise 4.4 Write a declaration of a private field named library that can hold an ArrayList. The elements of the ArrayList are of type Book. Exercise 4.7 Write assignments to the library, cs101, and track variables (which you defined in the previous three exercises) to create the appropriate ArrayList objects. Write them once using diamond notation and once without diamond notation, specifying the full type. Exercise 4.8 If a collection stores 10 objects, what value would be returned from a call to its size method? Exercise 4.11 Write a method call to add the object held in the variable favoriteTrack to a collection called files. Exercise 4.12 Write a method call to remove the third object stored in a collection called dates. Exercise 4.13 Suppose that an object is stored at index 6 in a collection. What will be its index after the objects at index 0 and index 9 are removed? Exercise 4.14 Add a method called checkIndex to the MusicOrganizer class. It takes a single integer parameter and checks whether it is a valid index for the current state of the collection. To be valid, the parameter must lie in the range O to size()-1. If the parameter is not valid, then it should print an error message saying what the valid range is. If the index is valid, then it prints nothing. Test your method on the object bench with both valid and invalid parameters. Does your method still work when you check an index if the collection is empty? Exercise 4.30 Write a while loop (for example, in a method called multiplesOfFive) that prints out all multiples of 5 between 10 and 95. Exercise 4.47 The makeABid method includes the following two statements: Bid bid = new Bid(bidder, value); boolean successful = selected Lot.bidFor (bid); The bid variable is only used here as a placeholder for the newly created Bid object before it is passed immediately to the lot's bidFor method. Rewrite these statements to eliminate the bid variable by using an anonymous object as seen in the enterLot method.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these algorithms questions
-
What particular strengths of the relational model have led to the pre-eminent position that it holds today as a vehicle for database management? [8 marks] Identify any weaknesses in the model,...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Stock A has a standard deviation of 7%. Stock B has a standard deviation of 12%. The correlation coefficient between the two stocks' returns is 0.4071. What is the risk (standard deviation) for an...
-
Netflix delivers movies for home entertainment, initially via efficient mail distribution but with prospects of dominating the new technology of electronic delivery. With the failure of Blockbuster...
-
Additional information: a. Annual depreciation of the equipment; $11,500. b. $12,000 of the Prepaid Insurance balance has expired. c. Unbilled and unrecorded revenues at year-end totalled $31,000....
-
Thirty-three percent of online consumers in Russia prefer to shop online using smartphones. You randomly select 12 consumers. Find the probability that the number of online consumers who purchase...
-
Bohlander Airlines is considering two alternatives for the financing of a purchase of a fleet of airplanes. These two alternatives are: 1. Issue 60,000 shares of common stock at $45 per share. (Cash...
-
What are the concept of learning styles, personalities, and how these concepts are combined with adult learning in organizational training and development programs ?
-
Target Corporation prepares its financial statements according to U.S. GAAP. Targets financial statements and disclosure notes for the year ended February 3, 2018, are available in Connect. This...
-
Q2. Elaine is a typical student and she spends her $200 allowance on beer (X) and books (Y). Her utility function is given by U = 20 XY and P X = $2 and P Y = $5. (a) Solve for Elaines optimal...
-
In order to find out the probability that a student will bring a car to campus, 1 0 0 students are polled. Of those students, 8 5 have cars to bring to campus. 1 . Find a point estimate for the...
-
For the next 20 years, Mr. Mudah plans to invest $650 a month in a stock account earning 6.5 percent and $400 a month in a sukuk account earning 4.5 percent. When he retires in 20 years, Mr. Mudah...
-
To be successful in college, time management is key and your first step will be developing a plan for your time. We all begin each week with 168 hours. Estimate the number of hours per week that you...
-
The wavelength of the laser is 5 3 0 nm . How many intensity maxima can be seen on the shaders placed behind the grating, when the grating has 3 4 0 slits per millimeter.
-
A corporation is working on its cash budget for March. The budgeted beginning cash balance is $ 3 3 , 0 0 0 . Budgeted cash receipts total $ 1 8 2 . 0 0 0 and budgeted cash disbursements total $ 1 9...
-
6. A sample of ionium (Th230) weighing 0.100 mg was found to undergo 4.32 X 106 disintegrations/min. What is the half-life of this nuclide? Ionium is formed by the a-decay of U234. How many...
-
Citing a scientific article, explain in your own words, how DNA fingerprinting has been used in forensic science to solve crimes and why it may not always be accurate or effective.
-
Bill and Guilda each own 50 percent of the stock of Radiata Corporation, an S corporation. Guilda's basis in her stock is $25,000. On July 31, 2012, Bill sells his stock, with a basis of $40,000, to...
-
On September 14, 2012, Jay purchased a passenger automobile that is used 75 percent in his accounting business. The automobile has a basis for depreciation purposes of $35,000, and Jay uses the...
-
Russell (age 50) and Linda (age 45) Long have brought you the following information regarding their income and expenses for the current year. Russell owns and operates a landscaping business called...
-
Explain the role of robotics and smart factories in manufacturing, services, and supply chains.
-
What is CAD/CAE? Provide one nontextbook example.
-
Research and write a short onetwo page paper on recent advances in robotics and their applications.
Study smarter with the SolutionInn App