Knowee
Questions
Features
Study Tools

elect the correct answerWhich of these is an incorrect array declaration?Optionsint arr[] = new[5] intint [] arr = new int[5]int arr[] = new int[5]int arr[] = int [5] new

Question

elect the correct answerWhich of these is an incorrect array declaration?Optionsint arr[] = new[5] intint [] arr = new int[5]int arr[] = new int[5]int arr[] = int [5] new

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

Solution

The incorrect array declaration is:

int arr[] = new[5] int

and

int arr[] = int [5] new

In Java, the correct syntax to declare an array is:

int[] arr = new int[5];

or

int arr[] = new int[5];

Similar Questions

Analyze the following code and choose the correct answer.int[] arr = new int[5];arr = new int[6];

Which of the following is incorrect? Group of answer choicesint[] a = new int[2];All are correctint[][] a = new int[2];int a[] = new int[2];

Select the correct answerWhat is the correct way to declare an array of integers in Java?Optionsint numbers[ ];numbers[ ];int[ ] numbers;array numbers[ ];

Analyze the following code and choose the correct answer.int[] arr = new int[5];arr = new int[6];The code has compile errors because the variable arr cannot be changed once it is assigned. The code has runtime errors because the variable arr cannot be changed once it is assigned.The code can compile and run fine. The second line assigns a new array to arr.The code has compile errors because we cannot assign a different size array to arr.

int arr[5]={89,67,54,90,39} syntax of array initialization

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.