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 method of heat transfer is used when the sun heats the earth?
monitta
Radiation is when heat travels through space.
8 0
4 years ago
How do you change your name because i really would like to change but i am not sure how to could someone help with it please
belka [17]
Goto your profile settings

3 0
3 years ago
The condition, ____, entered in the criteria row of a long text field in a query window would retrieve all records where the lon
skad [1K]
A query criterion<span> is an expression that Access compares to query field values to determine whether to include the record that contains each value</span><span>
The condition, *education, entered in the criteria row of a long text field in a query window would retrieve all records where the long text field had any mention of education.</span>
6 0
3 years ago
Define binary number and decimal number with example​
photoshop1234 [79]

Answer:

The Decimal Number System is a number system for which every real number x can be written in terms of the ten digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 as the sum of powers of 10. A number in the decimal number system is said to be of base 10 and to specify this we attach a subscript 10 to x, written (x)10.

The Binary Number System is a number system for which every real number x can be written in terms of the two digits 0 and 1 as the sum of powers of 2. A number written in the binary number system is said to be of base 2, and to specify this we attach a subscript 2 to x, written (x)2.

4 0
3 years ago
When a machine on the public network wants to reach the server at 172.30.0.10, which ip will it use?
Anton [14]
The IP address that it will use is 192.168.16.100
3 0
4 years ago
Read 2 more answers
Other questions:
  • Achieving a degree in computer forensics, information technology, or even information systems can provide a strong foundation in
    11·1 answer
  • Which of the following is not an algorithm?
    8·1 answer
  • Java
    13·1 answer
  • Consider the following method:
    8·2 answers
  • At what point in a vulnerability assessment would an attack tree be utilized?
    9·1 answer
  • Assume that two parallel arrays have been declared and initialized: healthOption an array of type char that contains letter code
    13·1 answer
  • Write a program to check if an input is a valid hashtag (starts with #, contains only letters, numbers, and underscore, no space
    6·1 answer
  • Access Help defaults to searching for information on the _________.<br><br> Not multiple choice
    10·1 answer
  • A programmer writing code in class Point attempts to override the following inherited method:public boolean equals( Object o ) {
    12·1 answer
  • Write a Python program that asks the user for a positive, odd value. Once the value is validated determine if the number is Prim
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!