Mala Gupta wrote:Now, can you determine the output of each of these lines of code?
Yes, I can. But I won't spoil the fun for others
And just for completeness, these lines are all equivalent:
String multiStrArr[][] = new String[][]{{"A", "B"},null,{"Jan", "Feb", null}};
String[] multiStrArr[] = new String[][]{{"A", "B"},null,{"Jan", "Feb", null}};
String []multiStrArr[] = new String[][]{{"A", "B"},null,{"Jan", "Feb", null}};
String[][] multiStrArr = new String[][]{{"A", "B"},null,{"Jan", "Feb", null}};
String multiStrArr[][] = {{"A", "B"},null,{"Jan", "Feb", null}};
String[] multiStrArr[] = {{"A", "B"},null,{"Jan", "Feb", null}};
String []multiStrArr[] = {{"A", "B"},null,{"Jan", "Feb", null}};
String[][] multiStrArr = {{"A", "B"},null,{"Jan", "Feb", null}};
Another (important) note: the brackets identify the array type and should appear with the type designation, so it's preferred to use
String[][] multiStrArr, but the other forms (e.g.
String[] multiStrArr[]) will also definitely appear on the exam. Don't let them fool you