Use the code written below to answer the question. Which statement is the correc
ID: 3831167 • Letter: U
Question
Use the code written below to answer the question. Which statement is the correct way to construct an object of the Book class? public class Book {private String author, private String title: public String isbn; public int numberOfPages public Book(String t String a String i, int n) {title = t: author = a isbn = i; numberOfPages = n:} public getAuthor() {return author} public getTitle() {return title:} private String getBookString{) {return title + + author + M [ISBN. " + isbn + Book myBook = new Book(): 0 Book myBook = new Bookf World WarZ". 'Max Brooks"); Book myBook = new BookfThe Stand Stephen King ISBN12345, 750 pages'); Book myBook = new BookfDante's Infemo", "Dante Alighieri'*. '12345'. 350).Explanation / Answer
Last option is the correct one.
Book myBook = new Book("Dante's Inferno","Dante Aligheiri","12345",350);
Book class has only one constructor and that too is a parameterised constructor.
Book class has no default cosntructor so new Book() is an invalid statement.
it has only 1 costructor with 4 parameters in this order :String,String,String,int
so Book myBook = new Book("Dante's Inferno","Dante Aligheiri","12345",350); is a valid statement.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.