?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Customer Accessor Method: Home Phone

APCSA-EB4WLT

Consider the following Customer class.

public class Customer 
{
    private int custNum; 
    private String firstName;
    private String lastName;
    private String homePhone = "";
    private double totPurchaseAmt = 0;;

    // other data and methods not shown
}

Which of the following methods could be coded in the Customer class so that other classes could access the home phone number of a Customer?

Customer joe = new Customer(100, "Joe", "King", "346-238-9435", 200.00);
System.out.println(joe._______________);  // print phone number of joe
A
public int getHomePhone()
{
    return homePhone;
}
B
public void getHomePhone()
{
    System.out.print(homePhone);
}
C
public String getHomePhone(String homePhone)
{
    return homePhone;
}
D
public String getHomePhone()
{
    return homePhone;
}
E
public void getHomePhone()
{
    return this.homePhone;
}