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 ‘is-a ‘ relationship in java?
What is nullpointerexception?
What are the Class Libraries ?
Does A Class Inherit The Constructors Of Its Superclass?
What is an abstract class and what is it’s purpose?
What are extraneous variables examples?
Can a static method be final?
What is boolean in java?
Find the value of a specified element of the array arr[i] where 0 <= i <= n-1
How are multiple inheritances done in Java?
How many types of assembly languages are there?
What happens to a static var that is defined within a method of a class?
What is += mean in java?
How big is a boolean?
How many arguments can be passed to main ()?