Question: 1. Im creating a Pizza object. It has the following characteristics: - Topping1 (String) - Topping2 (String) - Topping3 (String) - Size (char) - Price

1. I’m creating a Pizza object. It has the following characteristics:

- Topping1 (String)
- Topping2 (String)
- Topping3 (String)
- Size (char)
- Price (double)

I am overloading the constructor for multiple toppings.

Which of the following objects would I consider valid?
    A.     Pizza pizza8 = new Pizza(“Bell Peppers”, “Olives”, “Mushrooms”, ‘M’, -14.99);
    B.     Pizza pizza72 = new Pizza(“Cheese”, ’S’, 12.99);
    C.     Pizza pizza10 = new Pizza(“Ham”, “Pineapple”, ‘M’, 15.99);
    D.     Pizza pizza534 = new Pizza(“Bacon”, “Jalapeños”, “Onions”, ’S’, 24.99);
    E.     Pizza pizza600 = new Pizza(“Pepperoni”, “Sausage”, “Mushrooms”, ‘L’, 19.99);

2. I am creating a custom object class called NativeHawaiianPlant. Which exception should I use to validate an instance of this class?
    A.     InputMismatchException
    B.     StringIndexOutOfBoundsException
    C.     FileNotFoundException
    D.     IOException
    E.     ArithmeticException
    F.     ArrayIndexOutOfBoundsException
    G.     None of these choices are correct

3. I’m working on this week’s assignment and I receive the error “unreported exception; must be caught or declared to be thrown”  What should I do to resolve the error?
    A.     None of these choices are correct
    B.     If working with an object in my driver class, catch the exception with try-catch
    C.     Create a custom exception to validate the object
    D.     If working on my object class’s mutator methods, catch the exception with try-catch
    E.     If working with an object in my driver class, declare that the method throws the exception
    F.     If working on my object class’s mutator methods, declare that the method throws the exception

4. Which of the following are true about exceptions?
    A.     We use the word extends because a custom exception is a subclass of Exception
    B.     When we create a custom object class, we can run a custom exception class to help us validate the object
    C.     When creating our custom exception class, we must have: instance variable(s)
    D.     When creating our custom exception class, we must have: constructor
    E.     When creating our custom exception class, we must have: accessor/mutator method(s)
    F.     When creating our custom exception class, we must have: toString method
    G.     None of these choices are correct

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answering Each Question Step by Step 1 Valid Pizza Object In objectoriented programming the validity of an object creation depends on how the constructor of the class is defined For a Pizza object ass... View full answer

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 Programming Questions!