Menu
Question Index
...

What will be the output of the following program.

class CalculateArea
{
    public static void main(String s[])
    {
        int width = 20;
        int breadth = 30;
        int area = 0;
        
        area = calculateArea(width, breadth, area);

        System.out.println("Area : " + area);
    }

    public static void calculateArea(int width, int breadth, int area)
    {
        area = width * breadth;
    }
}


Area : 0
Area : 600
Compilation Error - since we can not assign the void return value from calculateArea to area.
Compilation Error - since we can not have the same parameter names as in the calling method.

Doubts

Problems

Topic: Is Java Pass by Reference or Pass by Value

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App