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
kipiarov [429]
3 years ago
13

What is the result of the following code?double[] values = new double[4];double sum = 0.0;for (int i = 1; i <= 4; i++) { sum

+= values[i];}System.out.println(sum);
Computers and Technology
1 answer:
jenyasd209 [6]3 years ago
7 0

Answer:

The following code as it is results in an array out of bound exception.

Explanation:

The reason for this exception is that you tried to access index 4 for an array of length four, because Arrays are indexed from zero, the last element in an array of length 4, will be at index 3 (i.e. 0,1,2,3)

To fix this change for (int i = 1; i <= 4; i++) to for (int i = 0; i < 4; i++).

In this way you code compiles and returns the sum of all elements in the array. Since this array is only created and empty, it outputs 0.0

You might be interested in
Which emails go to the draft folder
castortr0y [4]

Answer:

Hi there, the only emails that go to the draft folder are the emails that you start to write and then you don't finish it so you can go back and finish writing it later.

Explanation:

<h2>Hope this helps!! Please consider marking brainliest! Have a good one!!</h2>
6 0
3 years ago
Read 2 more answers
Why is democracy the best form of government
julia-pushkina [17]

Democracy is the best form of government simply because no other form of government is known to work well. Democracy may have its flaws but all in all it .

3 0
3 years ago
What is the name of the virus that appears to be a legitimate program?
timurjin [86]
A virus or malware appearing/pretending to be a legitimate program is called a Trojan. 
3 0
3 years ago
You have heard that the Linux distribution your are going to install to run a new application runs best on a RISC architecture.
Artyom0805 [142]

Answer:

SPARC .

Explanation:

When the user has understood they're required to install the linux distribution to set up a specific program works better on such a RISC architecture. SPARC must therefore find the device from which it would work that following distribution for the Linux. It is a RISC and ISA that was previously designed through both Fujitsu and Sun.

6 0
3 years ago
Jackson builders is constructing new homes in the Parkway subdivision.The company needs the logic for an application that ncalls
lord [1]
<span>The calculatePrice() method can be written in C. It will use and return doubles (which allows for decimals). It will calculate the house price of $100K + $20K per bedroom and $30K per bathroom. Next it will take that price and append the sales percentage and return that value.
double calculatePrice(decimal numBedrooms, decimal numBathrooms, decimal salesPercentage)
{
decimal housePrice = 100000 + (20000 * numBedrooms) + (30000 * numBathrooms);
return housePrice + (housePrice * salesPercentage);
}</span>
8 0
4 years ago
Other questions:
  • Ushahidi is a crisis-mapping tool that makes information instantly available to anyone in the world. T/F
    10·1 answer
  • PLEASEEE HELPPPP me
    13·1 answer
  • Anna is looking for a job. Which two types of skills would she find necessary to secure a job ?
    5·1 answer
  • Given an integer n and an array a of length n, your task is to apply the following mutation to an: Array a mutates into a new ar
    5·1 answer
  • What should you do to organize a large amount of data??
    10·1 answer
  • Your organization recently deployed a Windows domain controller with Active Directory. All the domain OU users need to run the s
    11·1 answer
  • Which symbol is at the beginning and end of a multiline comment block? &amp;&amp;&amp; """ %%% ###
    5·1 answer
  • Universal Containers uses a custom object within the product development team. Product development, executives, and System Admin
    11·1 answer
  • Computer technology has changed our lives write of a least five ways to show how this is so​
    15·1 answer
  • If you want to join all of the rows in the first table of a SELECT statement with just the matched rows in a second table, you u
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!