1
visibility

What will be the output of below statements?

String s = “Java String Quiz”;
System.out.println(s.charAt(s.toUpperCase().length()));

  • A

    Convert “Z” to int 90 and prints “90”

  • B

    Runtime Exception

  • C

    Prints “z”

  • D

    Prints “Z”

It will throw the runtime exception.Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 16 It’s because the index value starts from 0.