Question
Option 4 : false / false
Detailed Solution
सही उत्तर false / false है।
Question:
What is the output of the following Java code? `String s1 = "abc"; String s3 = new String("abc"); System.out.println(s1 == s3);` / निम्नलिखित Java कोड का आउटपुट क्या होगा? `String s1 = "abc"; String s3 = new String("abc"); System.out.println(s1 == s3);`
Correct Answer: false / false
`==` on objects compares references, not content: `s1` refers to the pooled literal while `s3` is a distinct heap object, so the result is false. The trap is confusing `==` with `equals()`, which would return true. / ऑब्जेक्टों पर `==` content की नहीं, reference की तुलना करता है: `s1` pooled literal को और `s3` एक अलग heap ऑब्जेक्ट को संदर्भित करता है, अतः परिणाम false है। जाल `==` को `equals()` समझना है, जो true लौटाता।