Computer Science : Common Data Structures

Study concepts, example questions & explanations for Computer Science

varsity tutors app store varsity tutors android store

Example Questions

1 2 3 5 Next →

Example Question #41 : Common Data Structures

Which of these instantiate a matrix called matrx with 5 columns and 4 rows that takes in integers?

Possible Answers:

int [] [] matrx = new int [] [5];

int [] [] matrx = new int [] [4];

int [] [] matrx = new int [4] [5];

int [] [] matrx = new int [5] [];

int [] [] matrx = new int [5] [4];

Correct answer:

int [] [] matrx = new int [] [4];

Explanation:

You create a matrix also known as a 2 dimensional array the same way you'd instantiate a normal array except the first array space remains blank and you'd insert the number for the amount of rows. Due to the fact that you want 5 columns and 4 rows, you'd only input the 4 into the second array.

1 2 3 5 Next →
Learning Tools by Varsity Tutors