मराठी

Given: int n = 0; int ar[] = new int [n]; ar[0] =25; System.out.print(" ar0] =“ + ar[0]); The code will generate ______.

Advertisements
Advertisements

प्रश्न

Given:

int n = 0;
int ar[] = new int [n];
ar[0] =25;
System.out.print(" ar0] =“ + ar[0]);

The code will generate ______.

पर्याय

  • no error

  • logical error

  • syntax error

  • runtime error

MCQ
रिकाम्या जागा भरा
Advertisements

उत्तर

The code will generate runtime error.

Explanation:

The array is created with size 0, so it contains no elements. Attempting to access ar[0] results in an ArrayIndexOutOfBoundsException at runtime because index 0 does not exist.

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 7: Arrays - One Dimension - Exercises [पृष्ठ १७२]

APPEARS IN

रूपा पंडित Computer Applications [English] Class 10 ICSE
पाठ 7 Arrays - One Dimension
Exercises | Q 1. (v) | पृष्ठ १७२
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×