Menu
Question Index
...

What will be the output of the following program?

public class IDontKnow {
    int calc(int[]... numbs) {
        int sum = 1;
        for (int[] numb : numbs) {
            for (int element : numb) {
                sum += element;
            }
        }
        return sum;
    }
    public static void main(String args[]) {
        IDontKnow numbers = new IDontKnow();
        int sum = 1;
        sum = numbers.calc({10, 20, 30}, {40, 10});
        System.out.println("The sum is : " + sum);
    }
}


The sum is : 50
The sum is : 110
The sum is : 111
Compilation Error
Runtime Error

Doubts

Problems

Topic: Static and Non Static Variables - Static and Non Static Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App