Core Java Interview Questions – String handling
This Core Java Interview Questions-Strings page provides all the core java interview questions about string handling in java including mutability, the immutability of object, StringBuffer class, StringBuilder class, string constant pool memory, synchronized strings, not synchronized strings and much more.
What is String?
Sting is a one-dimensional character array.
Is string object in java?
String is a predefined class in java
Strings are objects in java.
What is Immutable Object?
Immutable object static cannot be changed once it has been created.
Is string immutable in java?
yes, the string is an Immutable object.
What are StringBuffer and StringBuilder classes?
Mutable classes(State can be modified) used to process Strings in java.
What is the difference between StringBuffer and StringBuilder?
StringBuffer is synchronized whereas StringBuilder is not.
What is String Pool area?
String Pool area stores String Objects.
Can we store duplicate objects in string pool area?
String Pool area doesn’t allow to store duplicate string objects.
How to store 2 string objects having the same content?
Single object and address shared to both the string variables.
Does String is thread-safe in Java?
Strings are immutable, so we can’t change its value in the program.
Hence it is thread-safe.
What is a string, intern?
String object in the string constant pool is called as String Intern.
You can create an exact copy of heap memory string object in string constant pool.
This process is called interning.