Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is ‘is-a ‘ relationship in java?

1020


What is nullpointerexception?

1068


What are the Class Libraries ?

1042


Does A Class Inherit The Constructors Of Its Superclass?

1067


What is an abstract class and what is it’s purpose?

957


What are extraneous variables examples?

1093


Can a static method be final?

1049


What is boolean in java?

966


Find the value of a specified element of the array arr[i] where 0 <= i <= n-1

978


How are multiple inheritances done in Java?

1134


How many types of assembly languages are there?

965


What happens to a static var that is defined within a method of a class?

1027


What is += mean in java?

995


How big is a boolean?

1031


How many arguments can be passed to main ()?

991