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
makvit [3.9K]
3 years ago
15

Implement a recursive java method to find the sum of the first n int's in a java int array. Max size 20.

Computers and Technology
1 answer:
oee [108]3 years ago
6 0

Solution:

public class SumOfArray {

private int[] a;

private int n;

private int result;

   public int sumOfArray(int[] a,int n) {

     this.a = a;//Max size is 20

     n = a.length;

     if (n == 0)  // base case

     return a[n];

     else

         return a[n] + sumOfArray(a, n-1);

     return result;

  } // End SumOfArray method

} // End SumOfArray Class  


You might be interested in
What is the language of computers?
myrzilka [38]

<em>Answer:</em>

<em>Computers have language of their own. It is called Binary language. </em>

<em>It’s a very simple language with just 2 symbols – 0 and 1. A computer stores all information in the form of 0’s and 1’s.</em>

3 0
3 years ago
Wouldn’t it be nice if whenever we messed up our life we could simply press ‘Ctrl Alt Delete’ and start all over?
Orlov [11]
Sure, if you want to delete things
8 0
4 years ago
Read 2 more answers
Which of the following code segments does not contain any errors?
Readme [11.4K]

Answer:

c. double triple(float n) { return (3 * n); }

Explanation:

In option a print is used to print integer.While printf is used in C to print something.

In option b there is no * operator between s s s it should be s*s*s.So it will give error.

In option d there is also no multiply operator * in between 3.14 2 r it should be 3.14*2*r.

So we can say that option c is error free.

8 0
3 years ago
The only type of donation you can make to a not for profit is to donate money
amm1812
The correct answer is true
5 0
3 years ago
Read 2 more answers
‘‘Anyone in the developed world can publish anything anytime, and the instant it is published, it is globally available and read
taurus [48]
The internet made huge changes to the way news and information were shared. While it was faster to use newspapers or magazines to spread information than it was to simply tell people, they were still very inefficient compared to today's technology. With the internet today, anyone can come online and learn about what's happening in the far corners of the world. Take your question, for instance. If there was no internet, you might have to post a notice somewhere, which could take days to answer. However, since you were able to post this on the internet, I'm able to answer it within five minutes of it being posted.
8 0
3 years ago
Other questions:
  • Microsoft windows is the least used operating system true or false?
    15·2 answers
  • Whereas lines of competition are clearly defined in the more established industries, in the Internet industry they are blurred a
    9·1 answer
  • When working with data returned from a query wizard, refreshing a query occasionally produces undesired results. if this occurs,
    9·1 answer
  • A network admin configures a static route on the edge router of a network to assign a gateway of last resort (the router that co
    9·1 answer
  • Some personal computer manufacturers provide a hard disk configuration that connects multiple smaller disks into a single unit t
    6·1 answer
  • Kevin has to decide on a financial service provider that will help him with his needs related to tax exemptions and payments. He
    10·1 answer
  • Which of the following is a negative effect of the rise in agricultural technology following World War II?
    5·1 answer
  • Describing Report Tools Functions
    9·1 answer
  • Research the significance of the UNIX core of macOS and write a few sentences describing your findings.
    8·1 answer
  • Which of the following statements is TRUE of a peer-to-peer network?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!