Computer Science, asked by mailtokamal7454, 1 year ago

Which of these is an incorrect array declaration?

a.int arr[] = new int[5]

b.int [] arr = new int[5]

c.int arr[] = new int[5]

d.int arr[] = int [5] new?

Answers

Answered by p1998p
1
Option D int arr[] = int [5] new is incorrect array declaration.


Operator new must be succeeded by array type and array size.
Answered by AskewTronics
2

Option d is the correct answer for the above question

Explanation:

An array is used to store multiple variable values of the same type with one variable and allocate the memory in continuous Passion. In java programming language when a user wants to declare an array then he can declare it with the help of that syntax which is used to create an object of the class. It is because the java is an object-oriented language.

  • The Option 'a' ("int arr[]=new int[5]") is the correct syntax because it creates the object of int array class with the help of a new keyword.
  • The Option b "int [] arr =new int[5]" is the correct syntax because it creates the object of int array class with the help of a new keyword.
  • The Option c "int arr[] = new int[5]" is the correct syntax because it creates the object of int array class with the help of a new keyword.
  • The Option d "int arr[] = int[5] new" is not the correct syntax because it does not create the object of int array because there is no constructor after the new keyword.

So the option d is the answer to the above question.

Similar questions