?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Print Last Customer Order from Integer Array

APCSA-DAY4GN

Consider the following class.

public class Customer 
{
    /*  Constructor method for Customer
     *  Precondition: ords will contain at least one customer order
     */
    public Customer(int cNum, String fName, String lName, 
                    String hPhone, double totPurch, int[] ords)
    {
        // implementation not shown
    }

    /* returns the array of customer order numbers */
    public int[] getOrders()
    {
        // implementation not shown 
    }

    /* returns last customer order number for this customer */
    public int getLastCustOrderNum()
    {
        // implementation not shown
    }

    // instance variables and other methods not shown
}

Given the following customer named Katy, which of the following segments of code from a main() method in another class would print the last customer order number for this customer?

int[] orders = {1002, 1925, 3245};
Customer katy = new Customer(56, "Katy", "Tucker", "346-288-9655", 200.00, orders);

I.
System.out.println(getLastCustOrderNum());

II.
System.out.println(katy.getOrders()[katy.getOrders().length-1]);

III.
System.out.println(katy.getLastCustOrderNum());
A

I only.

B

III only.

C

I and III only.

D

II and III only.

E

I, II, and III.