KnowledgeBoat Logo
|

Computer Applications

Which of the following statements are valid array declaration ?

  1. int number( );
  2. float average[ ];
  3. double[ ] marks;
  4. counter int[ ];

Java Arrays

12 Likes

Answer

float average[ ];
double[ ] marks;

Reason — The statements float average[ ]; and double[ ] marks; are valid as they follow the syntax for declaration of an array.

int number( ); uses small brackets () instead of square brackets []. The correct statement will be int number[];.

counter int[ ]; has exchanged the place of data type and array variable. The correct statement will be int counter[];

Answered By

4 Likes


Related Questions