Menu
Question Index
...

What will be the output of the following program.

class MethodsTest
{
    public static void main(String s[])
    {
        float m = 34;
        float n = 56;
        double x = 21.0;
        double y = 98.0;
        boolean b = m < n;
        int o = (int) operate(m, n, x, y, b);
        System.out.println("o = " + o);
    }
    
    public static float operate(double d1, double d2, double d3, double d4, boolean d5)
    {
        System.out.println("d1 = " + d1 + " d2 = " + d2);
        System.out.println("d3 = " + d3 + " d4 = " + d4);
        return d5 ? d1 + d2 : d3 - d4;
    }
}


d1 = 34.0 d2 = 56.0
d3 = 21.0 d4 = 98.0
o = -77
d1 = 21.0 d2 = 98.0
d3 = 34.0 d4 = 56.0
o = 90
d1 = 34.0 d2 = 56.0
d3 = 21.0 d4 = 98.0
o = 90
Compilation Error

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