Java OCA OCP Practice Question 579

Question

How many of the following are legal declarations?

float[] lion = new float[]; 
float[] tiger = new float[1]; 
float[] bear = new[] float; 
float[] my = new[1] float; 
  • A. None
  • B. One
  • C. Two
  • D. Three


B.

Note

Since no elements are being provided when creating the arrays, a size is required.

Therefore, lion and bear are incorrect.

The braces containing the size are required to be after the type, making my incorrect.

The only one that is correct is tiger, making the correct answer Option B.




PreviousNext

Related