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
When should the method invokelater() be used?
What is exception handling in java?
Explain the difference between runnable and callable interface in java?
How many classes can any class inherit java?
What are the data types supported by java? What is autoboxing and unboxing?
What is thread count in java?
What is replacefirst in java?
What is the purpose of static methods and static variables?
What is a method in coding?
Is it possible for a yielded thread to get chance for its execution again?
What is try-with-resources in java?
What are bind parameters?
What is definition and declaration?
describe method overloading
How do you create a reference in java?