Veeva Systems interview question

String foo = "abc"; String foo1 = "abc" what does (foo == foo1) evaluate to?

Interview Answers

Anonymous

10 Dec 2012

Interviewer was wrong. You were correct.

Anonymous

3 Jan 2013

better say it's based on different situations

Anonymous

6 Feb 2012

I thought it was true because hey would be referencing the same object in memory because of String interning. Told the answer was false.

Anonymous

8 Feb 2012

You are correct. I checked it with a compiler.

2

Anonymous

19 Jul 2012

This situation is same as new String("abc") == new String("abc") rather than "abc"=="abc". so you was wrong.