English

Given: int a[ ] = new int [5];//declaration of array a[3]=5; The code will generate ______.

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]

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×