Multiple choice technology programming languages

  1. Select all correct declarations, or declaration and initializations of an array?

  1. a. String str[];

  2. b. String str[5] = new String[5];

  3. c. String str[] = new String[] {"string1", "string2", "string3", "string4", "string5

  4. d. String str[] = {"string1","string2", "string3", "string4", "string5"};

Reveal answer Fill a bubble to check yourself
A,C,D Correct answer
Explanation

Option A is a valid declaration. Option C and D are valid initializations. Option B is invalid because you cannot specify the array dimension on the left side of the assignment in Java.