Q. Which of these is a valid declaration of a two-dimensional array?

A
int[][] arr = new int[2][3];
B
int arr[][] = new int[2,3];
C
int[] arr = new int[2][3];
D
int arr[2][3] = new int[];
Solution:

A two-dimensional array is declared with two sets of square brackets, e.g., int[][] arr = new int[2][3].

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!