Examveda

Which one of the following is a valid statement?

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

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

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

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

Answer: Option B

Solution (By Examveda Team)

The syntax for declaring and creating an array variable in java is:
dataType[] arrayRefVar = new dataType[arraySize];

Thus, option (A) and option (C) is syntactically wrong as parentheses( ( ) ) is used instead of square brackets( [ ] ).
Option (D) is incorrect as the size of the array is missing.


This Question Belongs to Java Program >> Array

Join The Discussion

Comments (5)

  1. Zeleke Guangul
    Zeleke Guangul:
    8 years ago

    all option are similar .so,how we differentiate they

  2. Deepchandchauhan Deepu
    Deepchandchauhan Deepu:
    9 years ago

    All option are same and also invalid option.

  3. Deepchandchauhan Deepu
    Deepchandchauhan Deepu:
    9 years ago

    All option are same and also invalid option.

  4. Rajya Lakshmi282
    Rajya Lakshmi282:
    9 years ago

    all options are same.How can we differentiate in between them?

  5. Ramakant Kumar
    Ramakant Kumar:
    9 years ago

    all option are same and invalid

Related Questions on Array