Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 4 : falsetrue
Advertisement
Detailed Solution
सही उत्तर falsetrue है।
Key Points
Helpful?
Question:
Consider the Java fragment: String s1 = new String("java"); String s2 = "java"; System.out.print(s1 == s2); System.out.print(s1.equals(s2)); What is printed? / Java कोड खंड पर विचार करें: String s1 = new String("java"); String s2 = "java"; System.out.print(s1 == s2); System.out.print(s1.equals(s2)); क्या मुद्रित होगा?
1.
truetrue
2.
truefalse
3.
falsefalse
4.
falsetrue
Correct Answer: falsetrue
== compares references: new String creates a heap object distinct from the pooled literal (false); equals() compares character content, which matches (true). / == संदर्भों की तुलना करता है: new String पूल्ड लिटरल से भिन्न हीप ऑब्जेक्ट बनाता है (false); equals() वर्ण-सामग्री की तुलना करता है, जो मेल खाती है (true)।
Downloaded from PrepSnap (prepsnap.in)