Imagine you are developing a text editor that frequently alters strings (like undo, redo, replace, cut, copy, and paste operations). Which class(es) would you utilize for efficient memory and performance management?

  • String and PhantomReference
  • StringBuffer and SoftReference
  • StringBuilder and WeakReference
  • StringJoiner and ReferenceQueue
In a text editor, where efficient memory and performance management are crucial, StringBuilder is used for in-place string manipulation, and WeakReference helps in memory management by allowing objects to be garbage collected when not strongly referenced. StringBuffer is thread-safe but may not provide the best performance. The other options are not suitable for such scenarios.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *