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
Is call by reference possible in java?
What are the basics of core java?
Explain the importance of import keyword in java?
Which is faster call by value or call by reference?
What is bytecode verifier?
What are static methods?
Give me some null interfaces in java?
Is multiple inheritance supported by java?
What is set and get methods in java?
How do I get 64 bit java?
How many types of design patterns are there?
What is bubble sorting in java?
What is pre increment and post increment in java?
What is sortedset in java?
Explain about map interface in java?