Menu
Question Index
...

What will be the output of the following program?

class ArrayOutput
{
    public static void main(String s[])
    {
        int[] input = {3, 5, 6, 7};
        int result = 0;
        int output = multiplyEveryElement(input, result);
        System.out.print("Result of multiplying every element = " + output + ".");
    }

    public static int multiplyEveryElement(int[] input, int result)
    {
        for(int i = 0; i < input.length - 1; i++)
        {
            result *= input[i];
        }
        return result;
    }
}


Result of multiplying every element = 210.
Result of multiplying every element = 90.
Result of multiplying every element = 0.
Throws ArrayIndexOutOfBoundsException

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App