Correct Answer - Option 2 : int array [][] = new int [4][5]
Concept:
Java is a high-level programming language developed by sun microsystems. Java is platform-independent, simple, portable, object-oriented, and secured language. In java, an array is an object which contains a similar type of element.
Explanation:
Elements of an array are stored in contiguous memory locations. A fixed set of elements can be stored in java array. An array is an object of dynamically generated classes in java. We can also declare anonymous arrays in java.
Two types of an array are single dimensional and multidimensional.
Single dimensional array syntax:
dataType []arr; OR
dataType arr[];
Multidimensional array: in this data is stored in the form of rows and columns.
We can initialize the array in java as :
int[][] array = new int [] []; OR
int array[][] = new int [][];
Here, in this question we have to allocate 2-d array of integers with 4 rows and 5 columns.It will be:
int array[][] = new int [4][5];