The following class outputs false when it is executed. The array provided in the main method has a-1 in it and should re
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
The following class outputs false when it is executed. The array provided in the main method has a-1 in it and should re
The following class outputs false when it is executed. The array provided in the main method has a-1 in it and should return true. There is one statement in this class that needs to be modified in order to output true (the correct output) Identify the line and provide only the corrected line. Please do not rewrite the whole class . This class makes sure that a given array of integers does not have or -1 author xyz • version May 9, 2022 public class ZeroAndNegative ne { 7 sain method public static void main(String[] args) { intl array_nums = { 50, 11, 12, 54, -1); System.out.println("Result: " + test(array_nums)); Hethod to check for zeros and negative one • paras numbers is the input array itu boolean public static boolean test(int numbers) for (int i = 0; i < numbers. Length: 144) if (numbers == 0 && numbers == -1) { return true; } } return false; Format Table
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!