Which of the following correctly declares a method that accepts one…

2024

Which of the following correctly declares a method that accepts one dimensional array of double as a parameter?

  1. A.

    public void fun(double *arr[])

  2. B.

    public void fun(double[] arr)

  3. C.

    public void fun(arr double[])

  4. D.

    public void fun(double arr)

  5. E.

    Question not attempted

Attempted by 548 students.

Show answer & explanation

Correct answer: B

In Java, arrays are declared using the '[]' notation after the data type. For a one-dimensional array of doubles, the correct parameter declaration is 'double[] arr'.

Option A uses 'double *arr[]' which is C-style pointer syntax and is invalid in Java.

Option B uses 'double[] arr' which correctly declares a one-dimensional array of doubles as a method parameter.

Option C has incorrect syntax with 'arr double[]' - the variable name should come after the type.

Option D declares 'double arr' which is a single double variable, not an array.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs