KnowledgeBoat Logo
|

Computer Applications

Correct statement to declare an integer array of 10 elements.

  1. int[ ] arr = new int[10];
  2. int arr;
  3. int arr (10);
  4. int ( ) arr = new int (10);

Java Arrays

6 Likes

Answer

int[ ] arr = new int[10];

Reason — The correct syntax to declare an array is as follows:

datatype[ ] array_name = new datatype[size];

The statement int[ ] arr = new int[10]; follows the correct syntax of array declaration.

Answered By

4 Likes


Related Questions