Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

Can options that are written qualify for hedge accounting?

Answered: 1 week ago

Question

At what level(s) was this OD intervention scoped?

Answered: 1 week ago