A single dimensional array has 50 elements, which of the following is the correct statement to initialize the last element to 100.

ICSE Class 10 Computer Applications PYQ · 2025 Specimen · Section A

1(xi)1 Mark · 2025 · Section A · 2025 Specimen

A single dimensional array has 50 elements, which of the following is the correct statement to initialize the last element to 100.

Show SolutionHide Solution↓

x[49]=100

Reason — In Java, arrays use zero-based indexing, meaning the first element of the array is at index 0. For an array with n elements, the last element is at index n - 1.
Given a single-dimensional array with 50 elements, the indices range from 0 to 49. Thus, the correct index for the last element is 49.

← Previous questionNext question →

Browse the free Computer Applications sample bank