Java OCA OCP Practice Question 761

Question

Which of the following statements are valid ?

Select 2 options

  • A. String [] v = new String [3]{ "a", "b", "c"};
  • B. String v [] = { "a ", " b", "c"};
  • C. String v = new String []{"a", "b", "c"};
  • D. String v [] = new String []{"a", "b", "c"};
  • E. String v [] = new String [] {"a" "b" "c"};


Correct Options are  : B D

Note

For Option A.

You cannot specify the length of the array ( i.e. 3, here) if you are using the initializer block while declaring the array.

For Option C.

here v is not declared as array of strings but just as a String.

For Option E.

There are no commas separating the strings.




PreviousNext

Related