29.7k views
5 votes
Assume that the following code compiles without error in a client of the Book class. What do you know about the Book class?Book book1 = new Book("Secret Coders", "Gene Luen Yang");Book book2 = new Book("Alan Turing: The Enigma", 2014);A. The Book class has one constructor.B. The author name may or may not be needed to construct a Book object.C. Both the book title and publication year are required to construct a Book object

2 Answers

2 votes

Answer:

Explanation: Option B

It has two constructors

Author Name is not required but is an option

User Elephant
by
5.2k points
0 votes

Answer:

Only B is correct.

Step-by-step explanation:

First of all, it has two constructors, and you can conclude that you do not need the book title and publication year because they said the code compiles without error and the examples they give us where one does not have an publication year so that is incorrect because they use the term "required". But B is correct because it says you MAY or MAY NOT need the author's name which is true! AND I just took the test and I am correct.

User Vishal Wadhawan
by
5.8k points