Ask Question

Suppose you wish to write a method that returns the sum of the elements in partially filled array. Which is the best choice for a method header? Group of answer choices public int sum () public int sum (int[] values, int currSize) public int sum (int[] values) public int sum (int[] values, int size, int currSize)

+2
Answers (1)
  1. 14 July, 10:57
    0
    The Method header to this question is "int sum (int[] values, int currSize) ".

    Explanation:

    According to the question, It is defined that choose the correct option which creates a method header sum and returns the sum of the array element. In given options, we choose option second because in this option method return type is int and use an integer variable that is "currSize" which calculate the sum and return its value and other option are not correct that can be described as:

    In the first option, we create a method but we do not pass any parameter so it will not calculate the sum of array elements. In the third option, we create a method but we pass only one parameter that is an array. So, it will not calculate the sum of array elements correctly. In the fourth option, In this method, we pass three parameters that are "values, size and currSize" in which the size parameter not use.

    That's why the answer to this question is option second which is "int sum (int[] values, int currSize) ".
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Suppose you wish to write a method that returns the sum of the elements in partially filled array. Which is the best choice for a method ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers