How many objects are created when we create String class
object using new operator?
Answer Posted / ravi
Eknath Wagadre is correct, Check this programme.
String s1 = "this is string";
String s2 = new String("this is string");
System.out.format("S1: %d, S2:%d \n",s1.hashCode(),s2.hashCode() );
System.out.println(s1.hashCode()==s2.hashCode() );
The both s1 and s2 have same hashCode, means only one object created.
| Is This Answer Correct ? | 0 Yes | 5 No |
Post New Answer View All Answers
What is the use of bufferedreader?
Can we access instance variables within static methods ?
Is java ee a framework?
How to print nodes of a Binary tree?
What does flag mean in java?
What is java objectoutputstream?
Write a program to print 15 random numbers using foreach of java 8?
What is treemap in java?
Can we sort set in java?
Define how destructors are defined in java?
How do you define a variable?
What is lossy conversion in java?
Why main function is static?
What is the range of the short type?
Is treeset sorted in java?