How many objects are created when we create String class
object using new operator?

Answer Posted / mahesh

yes two objects will be created when you use new operator
for a String. The reason for this is at first it creates an
object in HEAP and then verifies in the String Constant
Pooling if it is not available then creates the new one in
pool. so totally two object will be created.

Is This Answer Correct ?    22 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is null statement?

538


Why is string builder not thread safe?

594


how many types of Inheritance?

657


What is difference between word and integer?

598


What is the intersection and union methods?

550






What is the difference between sleep and wait in java?

515


Write a function for palindrome and factorial and explain?

661


Why map is used in java?

584


What is anagram word?

523


Can you add null to a list java?

587


How big is a gigabyte?

621


What is adapter in java?

521


what invokes a threads run() method? : Java thread

574


What is mean by collections in java?

567


What is java volatile?

545