Total Pageviews

Tuesday, September 9, 2014

Important InterView Question in Java


 Difference between String and String Buffer......


String

String is immutable  ( once created can not be changed )object  . The object created as a String is stored in the  Constant String Pool  . 
Every immutable object in Java is thread safe ,that implies String is also thread safe . String can not be used by two threads simultaneously.
String  once assigned can not be changed .

String  demo = " hello " ;
// The above object is stored in constant string pool and its value can not be modified.


demo="Bye" ;     //new "Bye" string is created in constant pool and referenced by the demo variable            
 // "hello" string still exists in string constant pool and its value is not overrided but we lost reference to the  "hello"string  

StringBuffer

StringBuffer is mutable means one can change the value of the object . The object created through StringBuffer is stored in the heap .  StringBuffer  has the same methods as the StringBuilder , but each method in StringBuffer is synchronized that is StringBuffer is thread safe . 

Due to this it does not allow  two threads to simultaneously access the same method . Each method can be accessed by one thread at a time .

But being thread safe has disadvantages too as the performance of the StringBuffer hits due to thread safe property . Thus  StringBuilder is faster than the StringBuffer when calling the same methods of each class.

StringBuffer value can be changed , it means it can be assigned to the new value . Nowadays its a most common interview question ,the differences between the above classes .
String Buffer can be converted to the string by using 
toString() method.

StringBuffer demo1 = new StringBuffer("Hello") ;
// The above object stored in heap and its value can be changed .
demo1=new StringBuffer("Bye");
// Above statement is right as it modifies the value which is allowed in the StringBuffer

For More :
http://javahungry.blogspot.com/2013/06/difference-between-string-stringbuilder.html

Thursday, September 4, 2014

Wanted for Java Development - Fresh Engineering Graduates and Fresh MCA graduates for MNC @ Chennai


Wanted for Java Development - Fresh Engineering Graduates and Fresh MCA graduates for MNC @ Chennai



You may forward this to your friends and relatives who
 require similar jobs.

Interested Candidates may send resume to:

sugaemployment@gmail.com    or
career@sugaconsulting.in

Contact N.Sugavanam. 

SUGA Employment Services,

( a Division of SUGA Consulting Services),

Office No,26, TNHB Complex, Luz Golden Enclave, 
Ground Floor,
180, Luz Church Road, Mylapore, Chennai - 600004

Landmark: Behind Luz Pillaiyar Temple, Behind 'MAX' Show Room

Mobile: Airtel: 99400-58497, Vodafone: 91768-71191,

 91766-11627, 91762-44979

http://suga-employment-services.blogspot.com/