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();

        OutPut1 t2 = fix(t);
        System.out.println(t.t + " ");

        OutPut1 t3 = fix(t2);
        System.out.println(t.t + " " + t3.t);

        OutPut1 t4 = fix(t3);
        System.out.println(t.t + " " + t4.t);
    }
    
    OutPut1 fix(OutPut1 t)
    {
        t.t += 5;
        return t;
    }
}

class OutPut1
{
    byte t = 24;
}


29
34 34
39 39
24
29 29
34 34
24
24 29
24 34
29
29 34
34 39
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