Question: JAVA OOP (b) The code below violates the rule on encapsulation. Re-write class libraryBook so that encapsulation is preserved. Class Book private String title private

JAVA OOP

JAVA OOP (b) The code below violates the rule on encapsulation. Re-write

(b) The code below violates the rule on encapsulation. Re-write class libraryBook so that encapsulation is preserved. Class Book private String title private int publishYear public Book (String title, double publishYear) { this.title = title; this.publishYear = publishYear } public String get Title(){return title:} public int getPublishYear ({return publishYear:} public void set Title(String title){this. title = title;} public void setPublishYear (int publishYear) { this.publishYear = publishYear: } } class libraryBook { private Book book: private String catalogue; public libraryBook (Book book, String catalogue this book = book; this.catalogue = catalogue; } public Book getBook(){return book:} public String getCatalogue ({return catalogue;} }

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!