Q1: [2] Answer the following questions based on the following code: interface Libraryltems ( void use()...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Q1: [2] Answer the following questions based on the following code: interface Libraryltems ( void use() { System.out.println(" I will use a library item."); } } class Book implements Libraryltems { public void use () { System.out.println("I am reading a book."); } } class PrintedBooks extends Book { public void use () { System.out.println("I am reading a printed book."); } } class AudioBooks extends Book { public void use () { System.out.println("I am listening to an audiBook."); } } class moviesDVDs implements Libraryltems { public void use() { System.out.println("I am watching moviesDVD."); } } public class PolymorphRef{ public static void main(String[] args) { Book] LibraryBooks = (new Printed Books (), new AudioBooks()); // (1) Libraryltems [] items = (new Book(), new PrintedBooks(), new moviesDVDs ()}; // (2) System.out.println("Using LibraryBooks:"); for (int i = 0; i < LibraryBooks.length; i++) LibraryBooks[i].use(); System.out.println("Using library items:"); for (int i = 0; i < items.length; i++) items[i].use(); a. b. // (4) // (3) Is it possible to create an object from the Libraryltems class. Explain why? There are compile errors in the program above. What is/are all the statement(s) that make the error? C. What is the output of this program, if you correct the error. d. Draw a complete class diagram that shows the relationships between all the classes defined in the program above. ( you must show different types of arrows depending of the type of class) Q1: [2] Answer the following questions based on the following code: interface Libraryltems ( void use() { System.out.println(" I will use a library item."); } } class Book implements Libraryltems { public void use () { System.out.println("I am reading a book."); } } class PrintedBooks extends Book { public void use () { System.out.println("I am reading a printed book."); } } class AudioBooks extends Book { public void use () { System.out.println("I am listening to an audiBook."); } } class moviesDVDs implements Libraryltems { public void use() { System.out.println("I am watching moviesDVD."); } } public class PolymorphRef{ public static void main(String[] args) { Book] LibraryBooks = (new Printed Books (), new AudioBooks()); // (1) Libraryltems [] items = (new Book(), new PrintedBooks(), new moviesDVDs ()}; // (2) System.out.println("Using LibraryBooks:"); for (int i = 0; i < LibraryBooks.length; i++) LibraryBooks[i].use(); System.out.println("Using library items:"); for (int i = 0; i < items.length; i++) items[i].use(); a. b. // (4) // (3) Is it possible to create an object from the Libraryltems class. Explain why? There are compile errors in the program above. What is/are all the statement(s) that make the error? C. What is the output of this program, if you correct the error. d. Draw a complete class diagram that shows the relationships between all the classes defined in the program above. ( you must show different types of arrows depending of the type of class)
Expert Answer:
Answer rating: 100% (QA)
c d Following is the correct executable Java code as follows Java Code ... View the full answer
Posted Date:
Students also viewed these algorithms questions
-
Answer the following questions based on the information presented for Cloud 9 in Appendix B of this book and in the current and earlier chapters. You should also consider your answers to the case...
-
Answer the following questions based on the information presented for Cloud 9 in Appendix B and in the current and earlier chapters. You should also consider your answers to the case study questions...
-
Answer the following questions based on the accompanying diagram.a. How much would the firm??s revenue change if it lowered price from $12 to $10? Is demand elastic or inelastic in this range?b. How...
-
If the molecular weight of air is 28.9, what is the density of air at atmospheric pressure and a temperature of 328.2 K? 1 atm = 1.013 x 10 5 N/m, the mass of a proton is 1.67262 x 10 -27 kg,...
-
A soft-drink manufacturer claims that its 12-ounce cans do not contain, on average, more than 30 calories. A random sample of 64 cans of this soft drink, which were checked for calories, contained a...
-
The following payments and receipts are related to land, land improvements, and buildings acquired for use in a wholesale ceramic business. The receipts are identified by an asterisk. a. Fee paid to...
-
There is a market for bets on the outcome of a coin toss. The possible outcomes are heads, tails, and edge. There are three assets traded in that market: Asset A pays \(\$ 1\) independent of the...
-
Refer back to Problem 14-15. Assume that Ybors management is considering a change in the firms capital structure to include more debt. Management would therefore like to analyze the effects of an...
-
Calculate the geometric mean return of an investment with five year returns of 10%, (15%), 12%, 8% and (5%).
-
What is a balanced scorecard? What is its primary objective?
-
We will determine the longest number when written in Roman numerals between 1 and 999. For example, the Roman numeral LXXVI has length of 5 characters. Let's look at powers of ten and multiples of...
-
Gale Company has the following inventory and purchases during the fiscal year ended December 31, 2023. Beginning Inventory Feb. 10 purchased Feb. 20 sold Mar. 13 purchased Sept. 5 Oct. 10 purchased...
-
If gear A is the driving gear with 80 teeth and gear B is the driven gear with 60 teeth. What is the power transmission from gear A to gear B? Gear ratio If gear A is the driving gear with 80 teeth...
-
A high gravity wall with a height of five feet, six inches is used to contain a soil with an equivalent fluid density of 30 pcf. If concrete has a density of 150 pcf, de- termine the wall's factor of...
-
A variable capacitor is constructed using two half-circles of conducting material (radius r = 12.0 cm, with a gap between the plates of 2.00 mm. The capacitance is varied by adjusting the angle such...
-
You throw a 10.0 kg pumpkin with a velocity of 1.00 m/s at your friend who is standing on a stationary skateboard. He catches the pumpkin and begins to roll away. The mass of your friend plus his...
-
Week 2: Homework Question 4 of 5 View Policies Current Attempt in Progress Oct. 1 Oriole Corporation provides security services. Selected transactions for Oriole are presented below. (a) (b) 2 4 (c)...
-
A business had revenues of $280,000 and operating expenses of $315,000. Did the business (a) Incur a net loss (b) Realize net income?
-
Consider an experiment that selects a cell phone camera and records the recycle time of a flash (the time taken to ready the camera for another flash). The possible values for this time depend on the...
-
Suppose that the recycle times of two cameras are recorded. The extension of the positive real line \(R\) is to take the sample space to be the positive quadrant of the plane \[ S=R^{+} \times R^{+}...
-
As in Example 2.1, camera recycle times might use the sample space \(S=R^{+}\), the set of positive real numbers. Let \[ E_{1}=\{x \mid 10 \leq x <12\} \quad \text { and } \quad E_{2}=\{x \mid 11 0\}...
Study smarter with the SolutionInn App