Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Given the following method, and an one dimensional int array- numbers, if call testMethod(numbers, 5) returns a -1, what information can we obtain from
Given the following method, and an one dimensional int array- numbers, if call testMethod(numbers, 5) returns a -1, what information can we obtain from the return value? public static int testMethod (int[] array, int target) { for (int i = 0; i < array.length; i++) == if (array[i] return -1; target) return i; Question 20 (5 points) Provide a method named rowSum which accepts a two dimensional int array as parameter, this method will find the sum of each row and store the result in a one dimensional int array. By the end, this method will return the result array. Hint: //initialize an one dimension array to store the result // for each row //row sum Question 21 (4 points) Provide a method named isIncreasing which accepts an one dimensional int array as parameter. It will check and return whether the elements stored in this array is sorted in increasing order or not. Return true for yes and false for no. (Hint: Use for loop to check if array[i] Given the following method, and an one dimensional int array- numbers, if call testMethod(numbers, 5) returns a -1, what information can we obtain from the return value? public static int testMethod (int[] array, int target) { for (int i = 0; i < array.length; i++) == if (array[i] return -1; target) return i; Question 20 (5 points) Provide a method named rowSum which accepts a two dimensional int array as parameter, this method will find the sum of each row and store the result in a one dimensional int array. By the end, this method will return the result array. Hint: //initialize an one dimension array to store the result // for each row //row sum Question 21 (4 points) Provide a method named isIncreasing which accepts an one dimensional int array as parameter. It will check and return whether the elements stored in this array is sorted in increasing order or not. Return true for yes and false for no. (Hint: Use for loop to check if array[i] Given the following method, and an one dimensional int array- numbers, if call testMethod(numbers, 5) returns a -1, what information can we obtain from the return value? public static int testMethod (int[] array, int target) { for (int i = 0; i < array.length; i++) == if (array[i] return -1; target) return i; Question 20 (5 points) Provide a method named rowSum which accepts a two dimensional int array as parameter, this method will find the sum of each row and store the result in a one dimensional int array. By the end, this method will return the result array. Hint: //initialize an one dimension array to store the result // for each row //row sum Question 21 (4 points) Provide a method named isIncreasing which accepts an one dimensional int array as parameter. It will check and return whether the elements stored in this array is sorted in increasing order or not. Return true for yes and false for no. (Hint: Use for loop to check if array[i]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Solution From the return value of 1 when calling testMethodnumbers 5 we can infer that the value 5 i...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started