Q. What are the OOPS features-
Ans.- Encapsulation, Inheritance, Abstraction, Polymorphism
Q. What is difference between String and StringBuffer-
Ans. String is immutable and StringBuffer is mutable class
When perform operations on string object, it will create new object, but in case of stringbuffer its will use same instance without creating new object.
Q. Difference between String declaration - String s1="string"; and String s=new String("string");
Ans. First one will create string in string pool and second will create the string object in hash memory.
Q. StringBuffer and StringBuilder
Ans.- StringBuffer and StringBuilder both are mutable
StringBuffer are having synchronize method and StringBuilder doesn't have any synchonized method.
StringBuffer are thread safe. StringBuilder are thread unsafe
No comments:
Post a Comment