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

Object-oriented inheritance models the

a. “is a kind of” relationship b. “has a” relationship c. “want to be” relationship d. “contains” of relationship Answer: a. “is a kind of”

Which statement is true about Java?

a) Java is a sequence-dependent programming language b) Java is a code dependent programming language c) Java is a platform-dependent programming language d) Java is

Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?