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 += 42;
        return tt;
    }
}

class OutPut1
{
    byte x = 42;
}


42 42 84
42 84 84
42 84 126
42 84 42
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