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

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter14: Files And Streams
Section: Chapter Questions
Problem 17RQ
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,