Multiple choice technology programming languages

intern method is used for

  1. Finding length of string

  2. Clearing elements in Vector

  3. Comparing two Strings

  4. None of above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The intern() method in Java's String class is used to return a canonical representation of the string from the string pool. It's primarily used for string comparison optimization - interned strings can be compared using == reference equality instead of equals() for content comparison.