Consider the following (partially defined) Java class Book . public class Book {
ID: 3614736 • Letter: C
Question
Consider the following (partially defined) Java classBook.
public class Book {
private String author;
private String title;
private int year;
private String publisher;
public Book (String a, String t, int y, String p) {
// ... code
} public Book() {
// ... code
} public String toString() {
// ... code
} public void displayBook() {
// ... code }
}
a. List the data fields (also known asproperties or instance variables) of the classBook.
b. How many constructors define the classBook.
c. Identify an overloaded entity defined by theclass Book. Explain.
d. List the methods defined by the classBook.
Explanation / Answer
a. privateString author; private String title; private int year; private String publisher; b.Constructors are methods with the same name as the classand no return type. They are listed below: public Book (Stringa, String t, int y, String p); public Book(); c.The constructor is technically overloaded because there aretwo constructors with the same name but with different parameters,creating different method signatures. d.Besides the two constructors, there are twoadditional methods: public StringtoString(); public void displayBook();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.