You are asked to create a method that accepts an array of integers and returns the highest value from that array.
Given the code fragment:
Which method signature do you use at line n1?
You are asked to create a method that accepts an array of integers and returns the highest value from that array.
Given the code fragment:
Which method signature do you use at line n1?
The correct method signature should be 'static int[] findMax(int[] max)' because based on the return statement in the provided code fragment, the method is supposed to return an array of integers. The suggested answer 'static int findMax(int[] numbers)' implies returning a single integer, which does not match the return type expected in the code fragment. Therefore, the correct signature is the one that returns an integer array.
Answer should be B as we want int array as response.
Correct answer is B!
The answer is C: static int findMax (int[] numbers)
Correct is Letter B because we want int array as response and I tested.
Don't be confused !! method : access modifier optional specifier return type methode name (parameters) static int findMax(int[]) static : because, the method is used directly in a static main method (the method exist alone without instanciating the class Test) int : return type, we want just the maximum int value from the array int[]: the method takes an array of int.
Answer is B
The answer is B
Judging by question, we need single value so I would take C. But in the code array is returned (strangely), so B
Correct answer is : B
Return type is int[]