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...

difference between String a; and String a=new String();?
y do v need to assign memory to the variable?

Answer Posted / saroj kumar biswal

String a;
jvm creates a reference & allocates memory for storing hashcode value

String a=new String();
jvm creates a object to String class in heap memory & returns the unique hexadecimal equivalent of that memory location which is stored in reference variable a as hashcode.

We dont need to assign memory to variable.because in java memory management is taken care by jvm automatically.Programmer need not worried about memory allocation issue.But yes jvm allocates memory for variable to store hashcode, if it is a referenced variable.If it is primitive type variable then jvm will not allocate extra memory for that variable.Because primitive types stored in object & there is memory allocated for object by jvm.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is string a wrapper class?

975


What are java annotations?

1083


What is the exact difference in between unicast and multicast object? Where we will use?

948


How do you add an arraylist to an array in java?

938


Explain java coding standards for classes or java coding conventions for classes?

1074


Should a main method be compulsorily declared in all java classes?

1008


What is Java Package and which package is imported by default?

1042


How many bytes is a string?

1089


Is an object null?

917


Which sorting algorithm is in place?

910


What are the types of literals?

1100


What is an class?

979


if u open login & logout ,how can udisplay the timelogin & logout members ?

2234


What do you understand by final value?

1008


What is the difference between state-based unit testing and interaction-based unit testing?

896