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
What is a java list?
Is java programming easy?
Explain the difference between intermediate and terminal operations in java8?
Can we execute a program without main() method?
What is the use of set in java?
What is data movement?
Is set ordered?
Can we call the run() method instead of start()?
What is the replace tool?
What is ternary operator?
Define an abstract class with reference to java.
is there a separate stack for each thread in java? : Java thread
What is a boolean used for?
In which order the iterator iterates over collection?
There are two classes named classa and classb. Both classes are in the same package. Can a private member of classa can be accessed by an object of classb?