Menu
Question Index
...

What will be the output of the following program?

public class IDontKnow {
    int calc(int[]... numbs) {
        int sum = 0, b, c;
        for (b = 0; b < numbs.length; b++) {
            for (c = 0; c < numbs[b].length; c++) {
                sum += numbs[b][c];
            }
        }
        return (sum);
    }
    public static void main(String args[]) {
        IDontKnow numbers = new IDontKnow();
        int sum = 1;
        sum = numbers.calc(new int[]{10, 20, 30, 40}, new int[]{40, 50, 60});
        System.out.println("The sum of the numbers is: " + sum);
    }
}


The sum of the numbers is: 25
The sum of the numbers is: 250
The sum of the numbers is: 251
Compilation Error or 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