Limited access

Upgrade to access all content for this subject

Consider the following code, which was written to remove all job titles that are long (greater than 20 characters). jobs is a String ArrayList of job titles.

    ArrayList<String> jobs = // full of job titles

    for (int i=0; i<jobs. size(); i++)
        if (jobs.get(i).length()>20)

Which of the following BEST describes the results of executing this code and whether it will function as intended?


Yes, it will remove all job titles from jobs.


No, it is not checking the length of a job title correctly.


No, it is not accessing an element from jobs correctly within the loop.


No, if two long job titles are next to each other in jobs, it will not remove the second one.


No, it will throw an error if the last job title in jobs is greater than 20 characters long.

Select an assignment template