MCQ
Single Best Answer
Not Set
QWhich one of the following is a valid statement?
ID: #2197
Array in Java
37,468 views
Question Info
#2197Q ID
Not SetDifficulty
Array in JavaTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option B
Explanation
char[] c = new char[5];
This line of Java code creates a new array of characters called "c" with a length of 5.
The "new" keyword is used to allocate memory for the array, and the "char[]" indicates that it is an array of characters. The number inside the square brackets [] specifies the size of the array, which in this case is 5.
So, the resulting variable "c" is an array that can hold up to 5 characters. Note that the elements of the array are initially set to the default value of the char data type, which is '\0' (the null character).
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic