Menu
Question Index
...

What will be the output of the following program?

public class Madam
{
    public static void main(String[] args)
    {
        int a = 5;
        System.out.println(cube(a));
    }
    static int cube(int theNum)
    {
        return theNum * theNum * theNum;
    }
}


125
Compilation Error because cube is already defined in the java.lang.Math class.
Throws an ArithmeticException.
Compilation Error or Runtime Error for some other reason.

Doubts

Problems

Topic: Java Methods - Parameter Passing And Scope

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App