Which of the following declaration is illegal?
Answer: D
Correct answer: char[] str = “...”;
C writes the brackets after the identifier, not after the type: char str[]. The form with the brackets before the name belongs to Java. The other three are all valid ways of holding a string, though the third truncates if the literal exceeds the declared size.
Please log in or register to report this question.