Question: Q1: [2] Answer the following questions based on the following code: interface Libraryltems ( void use() { System.out.println( I will use a library item.);

Q1: [2] Answer the following questions based on the following code: interface

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)

Step by Step Solution

3.43 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

c d Following is the correct executable Java code as follows Java Code ... View full answer

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 Algorithms Questions!