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
How many digits is int32?
What is static class
What is the purpose of format function?
Is null an object in java?
What does math floor () do?
What is :: operator in java 8?
What is the ==?
What is a instance variable?
Explain listiterator and methods in listiterator?
What are the two ways to create a thread?
Which java version is latest?
What is the purpose of declaring a variable as final?
What is array initialization in java?
Define locale.
Is nan false?