Knowee
Questions
Features
Study Tools

List the correct ways of declaring an Array.Select one or more:a.String name[]=new String(10);  b.int studentId[10];c.int studentId[ ];d.int [ ]studentId;e.String [ ] name [ ];

Question

List the correct ways of declaring an Array.Select one or more:a.String name[]=new String(10);  b.int studentId[10];c.int studentId[ ];d.int [ ]studentId;e.String [ ] name [ ];

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct ways of declaring an array in Java are:

c. int studentId[ ]; d. int [ ]studentId; e. String [ ] name [ ];

Option a is incorrect because when declaring an array in Java, you don't specify the size at the time of declaration. The correct way would be: String name[] = new String[10];

Option b is incorrect because you cannot specify the size of the array at the time of declaration. The correct way would be: int studentId[] = new int[10];

This problem has been solved

Similar Questions

Which of the following statements correctly declares an array in Java? a. int[] numbers = new int(); b. int numbers[] = new int[10]; c. int numbers[10] = new int(); d. int numbers = new int[10];

What is wrong with the following code?int n = 5;int array[5];int i = 3;array[n] = i;It is impossible to declare the variable array this wayThe array array is not entirely initializedWhile it is possible to access array[n], we are not supposed to as this is not the array anymoreNothing is wrongI don't knowSubmit

How do you create a String array  called shoppingCart? Question 10Answera.String() shoppingCart = new String(5);b.String[ ] shoppingCart = new String[5];c.String[ ] shoppingCart = new Array[];d.string[ ] shoppingCart = new string[5];e.String[ ] shoppingCart = new String[];

"Select CORRECT statements related to this array:int[] ageArray = {14, 29, 45};"Data type of the array is string.Array has 2 indexes.The name of the array is int.The value 14 is in the zeroth index.The length of the array is 3.

Which of the following syntax correctly declares an Array in C/C++?int geeks;array geeks[20];geeks{20};int geeks[20];

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.