Menu
Topics Index
...
`

Method


If you need explanation Read this topic

If you need Answer Take test on this topic

Method
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;
    }
}

A. 125
B. Compilation Error because cube is already defined in the java.lang.Math class.
C. Throws an ArithmeticException.
D. Compilation Error or Runtime Error for some other reason.
Topic: Java Methods - Parameter Passing And Scope

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans is A bcoz func is called wth 5 as argumnt and it returns 5*5*5 = 125

Posted by Ratan Dhoka    2013-06-24 03:31:51


Congratulations to Ratan Dhoka. You are this dose winner. Please send us your mobile details and we will process the recharge asap.

Posted by Merit Campus    2013-06-24 08:05:18


© meritcampus 2019

All Rights Reserved.

Open In App