Limited access

Upgrade to access all content for this subject

Consider the following method.

 * @param oldContacts – fully populated array of contact names
 * @param newContacts - new array initialized with default String values
 * @return total length of all contact names
public static int copyContacts(String[] oldContacts, String[] newContacts)
    for(int i=0; i<oldContacts.length; i++)
        newContacts[i] = oldContacts[i];

    int totLen = 0;
    for (String contact : newContacts)
        totLen +=contact.length();
    return totLen;

What condition would cause this method throw a NullPointerException?


It will always throw a NullPointerException.


It will never throw a NullPointerException.


When oldContacts contains more elements than newContacts.


When newContacts contains more elements than oldContacts.


When both oldContacts and newContacts have a size of 0.

Select an assignment template