Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaString.intern and poolSingle-choice MCQ

Two String objects a and b are created so that a.equals(b) is true but a != b at runtime. After executing a.intern() and b.intern() (return values discarded), which guarantee can you rely on about subsequent intern() calls?

String a = new StringBuilder("ab").append("cd").toString(); String b = new StringBuilder("a").append("bcd").toString(); a.intern(); b.intern(); String x = a.intern(); String y = b.intern();