Menu
Question Index
...

What is the output of the following program?

public class Output {
    public static void main(String s[]) {
        Output o = new Output();
        o.string();
    }
    void string() {
        Output1 t = new Output1();
        System.out.print(t.x);
        Output1 t2 = fix(t);
        System.out.println(" " + t.x + " " + t2.x);
    }
    Output1 fix(Output1 tt) {
        tt.x += 42;
        return tt;
    }
}
class Output1 {
    byte x = 42;
}


42 42 42
42 42 84
42 84 42
42 84 84

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