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 = 50;
}


250
1250 1250
6250 6250
-6
-30 -30
106 106
250
250 1250
1250 6250
-6
-6 -30
30 106
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