Which of the following return true?
1. "john" == "john"
2. "john".equals("john")
3. "john" = "john"
4. "john".equals(new Button("john"))
Select all correct answers.
---
I think only 1 should be the answer but I have seen 1 and 2 both are correct answers. In option 2, according to my understanding, this should not true as "john" making a static text that should not be able to call equals() method.
What I can think of is JVM is converting that static text as a
string object. Is this correct?
If you can explain it more that wud be appricialble.
Thanks.