Question: Consider the following method, count, which is intended to traverse all the elements in the two - dimensional ( 2 D ) String array things

Consider the following method, count, which is intended to traverse all the elements in the two-dimensional (2D) String array things and return the total number of elements that contain at least one "a".
public static int count(String[][] things)
{
int count =0;
for (int r =0; r < things.length; r++)
{
for (int c =0; c < things[r].length -1; c++)
{
if (things[r][c].indexOf("a")>=0)
{
count++;
}
}
}
return count;
}
For example, if things contains {{"salad", "soup"},{"water", "coffee"}}, then count(things) should return 2.
The method does not always work as intended. For which of the following two-dimensional array input values does count NOT work as intended?
Responses
{{"lemon"},{"lime"}}
{{"lemon"},{"lime"}}
{{"tall", "short"},{"up", "down"}}
{{"tall", "short"},{"up", "down"}}
{{"rabbit", "bird"},{"cat", "dog"},{"gecko", "turtle"}}
{{"rabbit", "bird"},{"cat", "dog"},{"gecko", "turtle"}}
{{"scarf", "gloves", "hat"},{"shoes", "shirt", "pants"}}
{{"scarf", "gloves", "hat"},{"shoes", "shirt", "pants"}}
{{"math", "english", "physics"},{"golf", "baseball", "soccer"}}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!