A

Admin • 833.24K Points
Coach

Q. How to access the last element of an array 'arr'?

  • (A) arr[arr.length]
  • (B) arr[arr.length - 1]
  • (C) arr[length(arr)]
  • (D) arr[-1]
  • Correct Answer - Option(B)
  • Views: 29
  • Filed under category Java
  • Hashtags: Java Array

Explanation by: Admin

Since indexing starts from 0, the last element is at arr.length - 1.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.