KnowledgeBoat Logo
|
LoginJOIN NOW

Computer Applications

What are actual and formal parameters of a function ?

User Defined Methods

6 Likes

Answer

The parameters that appear in the method call statement are called actual parameters.

The parameters that appear in the method definition are called formal parameters.

For example,

class ParameterDemo  
{
    double square(double x)    {
        return Math.pow(x,2);
    }
    
    public static void main(String args[])
    {
        ParameterDemo obj = new ParameterDemo();
        double n = 5.3;
        double sq = obj.square(n);
    }
}

Here, x is the formal parameter and n is the actual parameter.

Answered By

3 Likes


Related Questions