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 thread life cycle?
How do I type unicode?
What is the byte order of byte buffer?
What is a "pure virtual" member function?
What is hashing principle in java?
What is the Scope of Static Variable?
What is difference between static variable and global variable?
What is the difference between a scrollbar and a scrollpane?
What is the difference between static and non-static variables in java programming?
What does provide mean construction?
Explain the difference between map and flatmap stream operation?
Why we cannot override static method?
How do you change an int to a string?
Is it possible to use string in the switch case?
Is empty .java file name a valid source file name?