DUET PG Score Card 2021
NHAI Recruitment 2021
Bihar Board 12th Dummy Admit Card 2022
RBI Assistant Notification 2021
Jee Advanced 2021 Result
NIACL Assistant Recruitment 2021
SBI PO Online Form 2021

Write a class SumOfIntegers with a public method calcSum that takes one parameter arr of type int[] and returns the sum of all integers in the arr. The return type of calcSum should be int

Write a class SumOfIntegers with a public method calcSum that takes one parameter arr of type int[] and returns the sum of all integers in the arr. The return type of calcSum should be int.

Here is an example:

Cmd Args : 1 3 5 7 9
Sum = 25

Fill in the missing in the below program.

Solution:

package q10876;
public class SumOfIntegers {
	public int calcSum(int[] arr) {
		int sum = 0;
		// Fill in the missing code for the for-each statement given below
		 for ( int value: arr  ) {
			sum += value;
		}
		// return the sum
		return sum;
	}
}

Candidates having any kind of query so he/she can ask in our comment section. Our Panel will b reverting back as soon as possible. Thank You. For more details visit our website (https://speedjobalert.com/)

Leave a Comment