Advertisements
Advertisements
Question
String a[] = {"Atasi", "Aditi", "Anant", "Amit", "Ahana"};
System.out.println(a[1].charAt(1) + "*" + a[2].charAt(2));
The output of the above statement is:
Options
da
d * a
ti
t * i
MCQ
Advertisements
Solution
d * a
Explanation:
- The array index starts from 0. So,
a[1]refers to the second element “Aditi”, anda[2]refers to the third element “Anant”. - In “Aditi”,
charAt(1)the second letter is ‘d’. - In “Anant”,
charAt(2)the third letter is ‘a’. - The
+operator joins the character ‘d’, the string “*”, and the character ‘a’ together, resulting in the output d * a.
shaalaa.com
Is there an error in this question or solution?
2025-2026 (March) Official Board Paper
