Ask Question

Assume that the classes BlankISBN, NegativePrice, and NegativeNumberOrdered are exception classes that inherit from Exception. The following code is a constructor for the Book class. What must be true about any method that instantiates the Book class with this constructor?

+4
Answers (1)
  1. 3 January, 10:38
    0
    public Book (String ISBNOfBook, double priceOfBook,

    int numberOrderedOfBook) throws BlankISBN,

    NegativePrice,

    NegativeNumberOrdered

    {

    if (ISBNOfBook = = "")

    throw new BlankISBN ();

    if (priceOfBook < 0)

    throw new NegativePrice (priceOfBook);

    if (numberedOrderedOfBook < 0)

    throw new NegativeNumberOrdered (numberOrderedv);

    ISBN = ISBNOfBook;

    price = priceOfBook;

    numberedOrdered = numberOrderedOfBook;

    }

    A) It must call the constructor with valid data or a compiler error will occur.

    B) It must contain an inner class that extends the IOException class.

    C) It must handle all of the possible exceptions thrown by the constructor or have its own throws clause specifying them.

    D) All of the above

    Explanation:

    the correct option is

    C) It must handle all of the possible exceptions thrown by the constructor or have its own throws clause specifying them.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assume that the classes BlankISBN, NegativePrice, and NegativeNumberOrdered are exception classes that inherit from Exception. The ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers