English

Java statement to access the 5th element of an array is:

Advertisements
Advertisements

Question

Java statement to access the 5th element of an array is:

Options

  • X[4]

  • X[5]

  • X[3]

  • X[0]

MCQ
Advertisements

Solution

X[4]

Explanation:

In Java, array indexing starts from 0, so the 1st element is at index 0, the 2nd element is at index 1, and the 5th element is stored at index 4. Therefore, arrayName[4] is used to access the 5th element.

shaalaa.com
  Is there an error in this question or solution?
Chapter 7: Arrays - One Dimension - Exercises [Page 174]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 7 Arrays - One Dimension
Exercises | Q 1. (xi) | Page 174
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×