There is an array of strings named strs. Which of the below Java statements correctly find the count of strings starting with character 'A' in this array of strings? 1. int cnt - 0; for (String s : strs) { if(s.charAt[0] == 'A') cnt++; } 2. int cnt - 0; for (int j = 0; j < strs.length(); j++) { if(strs[j].charAt (0) == 'A') cnt++; } 3. int cnt = 0; for (String s: strs) { if(s.charAt(0) == 'A') cnt++; } 4. int cnt = e; for (int j = e; j< strs.length; j++) { if(strs[j].charAt (8) == 'A') cnt++; } Lüffen birini seçin: O a. Only 4 O b. 3 and 4 O c. Only 1 O d. Only 3 O e. Only 2

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 11RQ
icon
Related questions
Question
There is an array of strings named strs.
Which of the below Java statements correctly find the count of strings starting with character 'A' in this array of strings?
1.
int cnt - 0;
for (String s : strs)
{
if(s.charAt[0] == 'A')
cnt++;
}
2.
int cnt - 0;
for (int j = 0; j < strs.length(); j++)
{
if(strs[j].charAt (0) == 'A')
cnt++;
}
3.
int cnt = 0;
for (String s: strs)
{
if(s.charAt(0) == 'A')
cnt++;
}
4.
int cnt = e;
for (int j = e; j< strs.length; j++)
{
if(strs[j].charAt (8) == 'A')
cnt++;
}
Lüffen birini seçin:
O a. Only 4
O b. 3 and 4
O c. Only 1
O d. Only 3
O e. Only 2
Transcribed Image Text:There is an array of strings named strs. Which of the below Java statements correctly find the count of strings starting with character 'A' in this array of strings? 1. int cnt - 0; for (String s : strs) { if(s.charAt[0] == 'A') cnt++; } 2. int cnt - 0; for (int j = 0; j < strs.length(); j++) { if(strs[j].charAt (0) == 'A') cnt++; } 3. int cnt = 0; for (String s: strs) { if(s.charAt(0) == 'A') cnt++; } 4. int cnt = e; for (int j = e; j< strs.length; j++) { if(strs[j].charAt (8) == 'A') cnt++; } Lüffen birini seçin: O a. Only 4 O b. 3 and 4 O c. Only 1 O d. Only 3 O e. Only 2
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT