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


String is mutable or immutable?

Answers were Sorted based on User's Feedback



String is mutable or immutable?..

Answer / tanveer

String class is immutable .To make the String immutable use String Buffer or String Builder classes which are mutable

Is This Answer Correct ?    14 Yes 4 No

String is mutable or immutable?..

Answer / sumitpalsingh

String class is immutable .In String class we can not change or modify object value. To make an object value modifiable. we can use StringBuffer and StringBuilder classes.

Is This Answer Correct ?    7 Yes 0 No

String is mutable or immutable?..

Answer / deep

String is neither immutable nor mutable, String is a class Lol.. and string objects are immutable cause you can't change the data which is stored inside in a object..

Let's take a example..
String a = "Dark Knight"; or String a = new String("Dark Knight");

now let's perform operation on String object..
there are some method you can perform on string object so i am gonna perform replace operation..
a.replace("Dark","Blue");

now try to display what's inside String object which is 'a'..
System.out.println(a); // Ans. Dark Knight

System.out.println(a.replace("Dark,"Blue"); // Ans. Blue Knight

but value inside string object is still Dark Knight so to get over this you have to create another object and you have to perform same action again..

String a = "Dark Knight" or String a = new String("Dark Knight");
String b = a.replace("Dark","Knight");

System.out.println(a); // Ans. Dark Knight
System.out.println(b); // Ans. Blue Knight

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

What are void methods?

0 Answers  


Is java written in c?

0 Answers  


Can inner class final?

0 Answers  


jdbc drivers?

8 Answers   Wipro,


Can arraylist hold different types java?

0 Answers  


Is empty string in java?

0 Answers  


What are the 4 versions of java?

0 Answers  


What is difference between iterator and enumeration in java?

0 Answers  


Why chararray() is preferred over string to store the password?

0 Answers  


Why main() method is public, static and void in java ?

0 Answers  


List types of storage classes in java?

0 Answers   Cyient,


waht happens when a return type ,even void is specified for a constructor?

11 Answers  


Categories