Computer Applications

The output of the below statement is:

String a[] = {"Atasi", "Aditi", "Anant", "Amit", "Ahana"};
System.out.println(a[1].charAt(1) + "*" + a[2].charAt(2));
  1. da
  2. d*a
  3. ti
  4. t*i

Java Arrays

2 Likes

Answer

d*a

Reason — In the array, a[1] is "Aditi", so a[1].charAt(1) gives 'd'. Similarly, a[2] is "Anant", so a[2].charAt(2) gives 'a'. The expression uses "*" as a String, so the + operator performs concatenation, resulting in "d*a".

Answered By

1 Like


Related Questions