How many objects are created when we create String class
object using new operator?
Answer Posted / rana
Answer is 2
String s = new String ("ABC"); // creates new obj in heap and adds entry in literal pool
String s1 = s.intern(); // fetches the existing object's value.
System.out.println(s1);
@Ravi
String hashCode has generic mechanism as below.
s[0]*31^n-1 + s[1]*31^n-2 ....+s[n-1]
n - length of string
s[0] - ascii value of the character
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Can a final method be overloaded?
How is string immutable in java?
How does map works in java?
Explain about the dynamic behavior of core java?
Explain the difference between comparator and comparable in java?
Why is stringbuffer called mutable?
What is meant by attribute?
What is the class in java?
What is string :: npos?
What are unchecked exceptions in java?
Can we create a constructor in abstract class?
What are the 6 mandatory procedures for iso 9001?
What is a class reference?
What is a constructor, constructor overloading in java?
How java is similar to c?