Menu
Question Index
...

What will be the output of the following program?

class Integer
{
    public static void main(String [] args)
    {
        Integer I = new Integer();
        I.string();
    }
    
    void string()
    {
        Integer2 t = new Integer2();
        System.out.print(t.x + " ");

        Integer2 t2 = fix(t);
        System.out.println(t.x + " " + t2.x);
    }
    
    Integer2 fix(Integer2 tt)
    {
        tt.x = 42;
        return tt;
    }
}

class Integer2
{
    byte x;
}


0 0 0
null null 42
0 0 42
0 42 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