Menu
Topics Index
...
`

Classes883


If you need explanation Read this topic

If you need Answer Take test on this topic

Classes883
What will be the output of the following program?
class OutPut
{
    public static void main(String []args)
    {
        OutPut O = new OutPut();
        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 tt)
    {
        tt.b = tt.a + tt.b + tt.c + tt.d + tt.e;
        return tt;
    }
}

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

A. 25 , 25 , 625 , 650 , 15650
5 , 5 , 10 , 55 , 105
180 , 105
B. 5 , 5 , 25 , 30 , 150
5 , 5 , 10 , 100 , 550
5 , 550
C. 5 , 5 , 25 , 30 , 150
5 , 5 , 10 , 100 , 550
670 , 670
D. 5 , 5 , 25 , 30 , 130
5 , 5 , 10 , 55 , 105
180 , 105
E. Compilation Error
Topic: Java Multiple Methods In One Class

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans b bcz
o.string()=>(local)b=5,a=5,c=25, d=30,e=150
output1 t=>a=5,b=5 c=10, d=100 e=550
fix(t)=>tt.b=670
but last t.a=5 ,t2.e=t.e=550

Posted by Pooja Singh    2014-08-05 12:58:14


Ans is B...Output class is called and the corresponding values of a,b,c,d,e are stored..Similarly in output1 and objects t and tt calls the class output1

Posted by Badam Swathi    2014-08-05 14:06:30


Congratulations Pooja Singh. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-08-06 04:50:58


© meritcampus 2019

All Rights Reserved.

Open In App