Which of the following statements represent a valid way to create a 2D array? an
ID: 3725607 • Letter: W
Question
Which of the following statements represent a valid way to create a 2D array? and why? Select all that apply.
String [][] allCompanions = new String[100];
String [][] allCompanions = {{"Susan", "Barbara"}};
String [][] allCompanions = {"Susan", "Barbara"}, {"Polly", "Ben"};
String [][] allCompanions = {{"Susan", "Barbara", "Ian"}, {"Polly", "Ben"}};
String [][] allCompanions = new String[13][];
String [][] allCompanions = new String[][11];
Which of the following statements represent a valid way to create a 2D array? and why? Select all that apply.
Answers:String [][] allCompanions = new String[100];
String [][] allCompanions = {{"Susan", "Barbara"}};
String [][] allCompanions = {"Susan", "Barbara"}, {"Polly", "Ben"};
String [][] allCompanions = {{"Susan", "Barbara", "Ian"}, {"Polly", "Ben"}};
String [][] allCompanions = new String[13][];
String [][] allCompanions = new String[][11];
Explanation / Answer
Answer:
String [][] allCompanions = {{"Susan", "Barbara"}};
String [][] allCompanions = {{"Susan", "Barbara", "Ian"}, {"Polly", "Ben"}};
String [][] allCompanions = new String[13][];
are valid 2D array statements.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.