Menu
Question Index
...

What will be the output of the following program?

class Public
{
    public static void main(String ARGS [])
    {
        Public O = new Public();
        int b = 25;
        O.string();
    }
    
    void string()
    {
        int b = 5;
        int a = b;
        int c = a * b;
        int d = c + a;
        int e = a + c * b;

        System.out.println(a + " , " + b + " , " + c + " , " + d + " , " + e);

        OutPut1 t = new OutPut1();
        System.out.println(t.a + " , " + t.b + " , " + t.c + " , " + t.d + " , " + t.e);

        OutPut1 t2 = fix(t);
        
        OutPut1 t3 = new OutPut1();
        System.out.println(t.a + " , " + t2.e);
    }
    
    OutPut1 fix(OutPut1 ARGS)
    {
        ARGS.b = ARGS.a + ARGS.b + ARGS.c + ARGS.d + ARGS.e;

        return ARGS;
    }
}

class OutPut1
{
    int a = 5;
    int b = a;
    int c = a + b;
    int d = a + b * c;
    int e = d + c * a;
}


25 , 25 , 625 , 650 , 15650
5 , 5 , 10 , 55 , 105
5 , 105
5 , 5 , 25 , 30 , 150
5 , 5 , 10 , 100 , 550
5 , 550
5 , 5 , 25 , 30 , 130
5 , 5 , 10 , 55 , 105
180 , 105
5 , 5 , 25 , 30 , 130
5 , 5 , 10 , 55 , 105
5 , 105
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