String a = "hello";
String b = "hello";
a == b will evaluate to true.
String a = new String("hello");
String b = new String("hello");
a == b will evaluate to false.
String literals in Java are put in to a string "heap" (might not be the correct word) and reused. Strings objects create a new instance for each string.
It's not terribly confusing, although syntax highlighters do treat them differently which I could see could confuse the uninitiated.
Perhaps author meant JavaScript, which does have primitive `string' type, distinct from instances of class `String'?
It could be that the author was shown a bit of code where an instance of a String was called string (I've seen this many times as an argument name especially in methods for converting or manipulating a String value). But since the code wasn't mentioned we have no idea,
Seems like a nasty trick question to ask of an intern who doesn't know Java!
It reminds me of an interview question I was asked once (thought not as bad as String/string): "What is the time complexity to print every node in a binary tree?"
Google is not proving fruitful for this question.