Which statement is true about the compilation and execution of the following program with assertions enabled?
public class Main { String s1;/*www . j a v a 2s . com*/ String s2 = "hello"; String s3; Main() { s1 = "hello"; } public static void main(String[] args) { (new Main()).f(); } { s3 = "hello"; } void f() { String s4 = "hello"; String s5 = new String("hello"); assert(s1.equals(s2)); // (1) assert(s2.equals(s3)); // (2) assert(s3 == s4); // (3) assert(s4 == s5); // (4) } }
Select the one correct answer.
(e)
All the "hello" literals denote the same String object.
Any String object created using the new operator will be a distinct new object.