The following class outputs false when it is executed. The array provided in the main method has a-1 in it and should re

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
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

Post by answerhappygod »

The Following Class Outputs False When It Is Executed The Array Provided In The Main Method Has A 1 In It And Should Re 1
The Following Class Outputs False When It Is Executed The Array Provided In The Main Method Has A 1 In It And Should Re 1 (37.82 KiB) Viewed 55 times
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!
Post Reply