Menu
Question Index
...

What will be the output of the following program?

class PassS {
    public static void main(String[] args) {
        PassS p = new PassS();
        p.start();
    }
    void start() {
        String s1 = "good";
        String s2 = fix(s1);
        System.out.println(s1 + " " + s2);
    }
    String fix(String s1) {
        s1 = s1 + "bad";
        System.out.print(s1 + " ");
        return "bad";
    }
}


good bad
goodbad bad
goodbad good bad
bad good bad
Compilation Error or Runtime 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