Menu
Question Index
...

What will be the output of the following program?

public class MTR {
    void method1(String str, int x) {
        str = new String("Hot");
        x = x + 1;
    }
    public static void main(String s[]) {
        String str1 = "Sweet";
        String str2 = "Sweet";
        int a = 1;
        new MTR().method1(str1, 10);
        new MTR().method1(str2, 20);
        System.out.println(str1 + " " + str2 + " " + a);
    }
}


Hot Hot
Hot 2 Hot 2
Sweet Sweet 1
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Conclusion Of Strings In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App