Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
91 views
in Information Technology by (95.2k points)
closed by
 Which of the following Java statements declare and allocate a 2-dimensional array of integers with four rows and five columns? 
1. int array [4][5];  
2. int array [][] = new int [4][5]
3. int array [5][4]; 
4. int array [][]= new int [5][4] 

1 Answer

0 votes
by (95.4k points)
selected by
 
Best answer
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];

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...