1.Q.What is String in Java?

Category: JAVA STRING INTERVIEW QUESTIONS AND ANSWERS

A String is a non-primitive data type which represent the sequence of characters enclosed in double quotes . String can conrain letters , numbers , spaces , symbols and punctuation .

Key characteristics of Java String are Immutability , Memory Optimization and constant pool. String is immutable because once a string object is created , its value cannot be changed . Java uses special memory location called String Constant Pool inside the heap memory .If you create multiple strings with same text literal , Java points to the same memory slot inside the Constant Pool to save space.

Leave a Reply

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