Menu
Question Index
...

What will be the output of the following program?

class OutPut
{
    public static void main(String []args)
    {
        OutPut O = new OutPut();
        O.string();
    }
    
    void string()
    {
        OutPut1 t = new OutPut1();
        System.out.print(t.x + " ");

        OutPut1 t2 = fix(t);
        System.out.println(t.x + " " + t2.x);
    }
    
    OutPut1 fix(OutPut1 tt)
    {
        tt.x -= 24;
        double y = tt.x;
        return y;
    }
}

class OutPut1
{
    int x = 42;
}


42 18 -6
42 18 18
42.0 18.0 -6.0
42.0 18.0 18.0
Compilation Error

Doubts

Problems

Topic: Java Multiple Methods In One Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App