Friday, 24 March 2017

Java Experiance InterView Questions and answer

--> Example of SingleTone in java 

public final class SingleTone {
   
    /**
     * @author anand
     *
     */
   
   
    public static SingleTone single;
    //Can be act as SingleTone or make constructor as private
   
    private SingleTone(){}
   
    public static synchronized SingleTone getInstance(){
       
        if(single==null){
           
            single=new SingleTone();
        }
        return single;
    }
   

}


--> What is difference between StringBuffer and StringBuilder in Java ?

# Stringbuffer methods are synchronized while StringBuilder is non synchronized. See StringBuilder vs StringBuffer for more differences.
 # StringBuffer as slow in performance since Thread Safe whereas StringBuilder in faster .






No comments:

Post a Comment

Java Interview question and answer

  Java Backend Interview Prep — Q&A Guide Java Backend Interview Prep 24 topics · 287 questions Expand all Collap...