Which of the following is a legal way to declare and instantiate an array of 10 Strings?

Which of the following is a legal way to declare and instantiate an array of 10 Strings?


a) String s = new String(10);

b) String[10] s = new String;

c) String[ ] s = new String[10];

d) String s = new String[10];

e) String[ ] s = new String;

9 4 12 2 6 8 18

Answer: c. Explanation: Declaring an array is done by type[ ] variable. Instantiating the array is done by variable =new type[dimension] where dimension is the size of the array. 


Java

Learn More Multiple Choice Question :