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 = calculateArea(width, breadth);

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

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


Area : 0
Area : 600
Compilation Error - since we can not have duplicate variable name area in
both main method and the calculateArea method.
Compilation Error - since we are not returning the area from
the calculateArea 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