Bird
0
0

Which statement about Java String methods is TRUE?

hard📝 Conceptual Q10 of 15
Java - Strings and String Handling
Which statement about Java String methods is TRUE?
AStrings are mutable and methods like replace() change the original string
BCalling toUpperCase() modifies the original string in place
Cequals() compares references, not content
DMethods like substring() return a new string without modifying the original
Step-by-Step Solution
Solution:
  1. Step 1: Recall String immutability in Java

    Strings are immutable; methods return new strings without changing original.
  2. Step 2: Evaluate each option

    A is false (Strings immutable), B is false (toUpperCase returns new string), D is false (equals() compares content).
  3. Final Answer:

    Methods like substring() return a new string without modifying the original -> Option D
  4. Quick Check:

    Java Strings are immutable; methods return new strings [OK]
Quick Trick: Java Strings are immutable; methods return new strings [OK]
Common Mistakes:
  • Thinking Strings change in place
  • Confusing equals() with == operator

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes