1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
KIM [24]
3 years ago
5

We have written a method called sum with an int[] parameter nums. We want our sum method to compute the sum of nums, but our cod

e has a bug (or perhaps bugs?) in it.
Fix the bugs.

Computers and Technology
1 answer:
ira [324]3 years ago
8 0

Answer:

Following are the code to this question:

public class Main//defining a class-main  

{

public static int sum(int[] nums)//defining a method sum that accepts array  

{

int total = 0;//defining integer variable total

for(int num : nums) // use for-each loop

{  

total += num;//add array value in total variable

}

return total;//use return keyword to return the total value

}

public static void main(String []ar )//defining a main method  

{

int[] nums={1,2,3,4,5};//defining 1-D array nums

System.out.println(sum(nums));//use print function to call sum method  

}

}

Output:

15

Explanation:

In the class "Main", a static method, "sum" is defined, that accepts array in its parameter and inside the method, an integer variable "total" is define, that uses the for each loop to add array value in a total variable and use a return keyword to return its value.  

Inside the main method, an integer array nums are defined, that holds store some values and use the print function to call the sum method.

You might be interested in
What font family is Times New Roman an what font family is Arial?
Alexxandr [17]

Answer:

Some Font Examples

Generic Font Family                 Examples of Font Names

Serif                    Times New Roman Georgia Garamond

Sans-serif                          Arial Verdana Helvetica

Monospace                     Courier New Lucida Console Monaco

Cursive                        Brush Script MT Lucida Handwriting

Explanation:

hope it help

4 0
3 years ago
Read 2 more answers
What symbol indicates that a cell is not wide enough to display its numbers ?
Yuki888 [10]

Answer:

Option D is correct. A pound sign is used to indicates that a cell is not wide enough to display its numbers.

Explanation:

A pound sign symbol indicates that a cell is not wide enough to display its number in Excel. However, it is noted that if you use or installed a US keyboard in your computer then hash symbol (#) is shown and the pound sign symbol is shown if you use or installed the UK keyboard layout in your computer.

Why other options are not correct.

  • An Asterisk symbol:

this symbol is used for multiplication in formula or in a cell to multiply the numbers with each other.

  • A dollar sign:

A dollar sign is used in a cell to show the currency. If you want to show the cell value as a currency. Then, you can use the dollar sign.

  • Percentage Sign

Percentage sign in the cell shows that value in a cell is representing a percentage of some values.

3 0
3 years ago
Read 2 more answers
In a bluesnooping attack, the attacker copies emails, calendars, contact lists, cell phone pictures, or videos by connecting to
Kay [80]
The answer is depends. You can only get what the port lets you get. If the phone bans sending photos over Bluetooth than you can’t get the photos
3 0
3 years ago
Write down the step to search information internet​
Novosadov [1.4K]

Answer:

Here u go... hope it helps u.... have a great day ahead

5 0
3 years ago
Data that can be used to identity a single individual is known as
lys-0071 [83]

Answer:

Fingerprint Recognition

Explanation:

3 0
4 years ago
Other questions:
  • The photo-sharing site Instagram owed a good deal of its success to filters. What are filters?
    11·2 answers
  • Why is a port scan detected from the same ip on a subnet an alarming alert to receive from yourids?
    5·1 answer
  • A voice engineer is setting up a Cisco 2951 Integrated Services Router with Cisco Unified Communications Manager Express. To ena
    6·1 answer
  • How many bytes of information can be stored on a hard drive?
    7·1 answer
  • All states that have altered judicial selection techniques in recent years have adopted some form of:
    5·1 answer
  • Missing slot covers on a computer can cause?
    9·1 answer
  • In what ways are hardware and software different? in what ways are the the same?
    10·2 answers
  • The right to make others do things is referred to as _________.
    14·2 answers
  • Use the drop-down menus to match the description to the correct audio-editing technique or term. deleting unwanted sounds increa
    14·2 answers
  • What is the deck of a suspension bridge called​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!