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
Which type of server runs Active Directory?
omeli [17]

Answer:C

Explanation:it authorizes and authenticates all users and computer in a window domain- type network assigning and enforcing security for all computers and installing or updating software

6 0
3 years ago
A(n ____ is information that a web server stores on a client computer, such as the client’s preferences when accessing a particu
gayaneshka [121]
<span>A COOKIE is information that a web server stores on a client computer, such as the client’s preferences when accessing a particular web site, or where the client has been on the web site.</span>
7 0
2 years ago
Which type of information should never be given out on social media?
zhenek [66]

Answer:

Sites like Face.book are full of valuable data for people who use social engineering to steal your identity on social media. You should therefore avoid sharing information that's used to verify your identity,

Explanation:

7 0
2 years ago
Read 2 more answers
Notes on secondary memory​
gladu [14]

Answer:

non-volatile and persistent in nature

7 0
3 years ago
Identify any eight new programming languages and classify them based on their functionality.
shepuryov [24]

Answer:

Some of the new programming languages are R, Python, Haskell, Swift, C++, Java, Javascript and PHP.

However, you should know that in general sense there are three types of programming languages.

R is a pure object-oriented programming language being used for scientific purposes, and now it is being used extensively for machine learning as well.

Python is also a pure object-oriented programming language, and it is being used for mainly machine learning. However, you need to keep in mind that it supports the functional programming paradigm as well.

Haskell is a functional programming language and is the best in the functional paradigm as well. You can compare it with LISP, FORTRAN and PASCAL or COBOL, and you will find that Haskell is the best.

Swift is a pure object-oriented programming language, And by pure it means it never cheats anybody like if it says a variable is an int, it will be an int and not like C# here a string data type can be an integer data type. And this is not the correct thing. However, if you study in deep, you will find it is a necessary evil.

C++ and Java are imperative programming languages.

The Javascript and PHP are the scripting languages that support the object-oriented programming concepts but not fully, and they too fall under the imperative programming language list.

Explanation:

The answer is self explanatory.

4 0
2 years ago
Read 2 more answers
Other questions:
  • Why is it a mistake to put e-mail address of people who don't know each other in the "to:" field
    9·2 answers
  • What type of file can most software applications read?
    5·2 answers
  • A media scholar is trying to find out whether internet or television political ads are more persuasive. what kind of effects is
    7·1 answer
  • Sue needs to add a header and a footer to a presentation. Which process should she use to do this?
    10·2 answers
  • What is thhe name of service included with windows server operating systemthat manages a centralized database containing user ac
    5·1 answer
  • Ryo currently earns a monthly salary of $2200. She has been offered a raise of $250 per month. How much more will she earn per y
    14·1 answer
  • ...................is a high level, structured , open source programming language​
    10·1 answer
  • The files in James's computer were found spreading within the device without any human action. As an engineer, you were requeste
    11·1 answer
  • Help me please. I dont really understand this.
    12·2 answers
  • Type the correct answer in the box. Spell all words correctly. Kenny is designing a document for the employee motivation campaig
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!