Important Java Mcq 1

Which of the following is one of the valid statements?

a. char[] c = new char();

b. char[] c = new char(4);

c. char[] c = new char[];

d. char[] c = new char[5];

Answer:

d. char[] c = new char[5];

Explanation:

The syntax for declaring an array is dataType[] arrName = new dataType[array  Size]; only the d option satisfies the syntax of array declaration. So, d is the right choice.

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?