Which of the following is a valid header for a method called \"sumArray\" that r
ID: 3849472 • Letter: W
Question
Which of the following is a valid header for a method called "sumArray" that returns the total sum of all values in the array containing integers. public static void sumArray(int[] array) public static sumArray(int[] array) public static int sumArray(int array[]) public static char sumArray(char array[]) Which of the following is a valid header for a method called "arrayDups" that returns the number of duplicate values in an array. public static void arrayDups(int array) public static char arrayDups (char[] array) public static arrayDups (int[] array) public static int arrayDups(char array[])Explanation / Answer
Q.4) which of the following is a valid header for a method called "sumArray()"" that returns the total sum of all values in the array containing integers.
Ans)
public static int sumArray(int array[]) is the answer because if we notice in the question we have to return the total sum of all integer numbers and a function header need return type as 'int' for that. So thats why this is the answer. Also note that to pass arrays to functions we can either do int[] array or int array[] both are same.
Q.5) which of the following is a valid header for a method called "arrayDups" that returns the number of duplicate values in an array.
Ans)
public static int arrayDups(char array[]) is the answer because we have to return number of duplicate values in an array which is an integer. The only function which has integer as the return type in the options is this header. Hence the answer.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.