Advertisements
Advertisements
Question
Given:
int a[ ] = new int [5];//declaration of array
a[3]=5;
The code will generate ______.
Options
no error
logical error
syntax error
runtime error
MCQ
Fill in the Blanks
Advertisements
Solution
The code will generate no error.
Explanation:
Declaring an array of size 5 creates valid slots from indices 0 to 4. Assigning a value to a[3] is perfectly safe because index 3 falls completely within this legal range.
shaalaa.com
Is there an error in this question or solution?
Chapter 7: Arrays - One Dimension - Exercises [Page 172]
