Posts

Showing posts with the label String constantpool

String interview questions and answers

String interview questions and answers are placed the current post as of my experience in interviews. This will helps who are trying to attend interview as fresher as well as experience. If any one is facing any other questions which are not present in the current page, please drop me an email to " subbareddynallamachu@gmail.com ".  Q1:  String is a class or data type? A: String is a class in java.lang package. But, in java, all classes are also are considered as data types. So we can take String as data type also. Q2:  What is the difference between == and equals() methods in java? A: == operator compares the references of the String object. It does not compare the content of the object. equals() method compares the contents. While comparing the Strings, equals method should be used as it yields the correct result. Q3:  What is String constant pool? A: String constant pool is a separate block of memory where the String objects are held by JVM....

How to create String, StringBuffer and StringBuilder in java

Image
Most of the data transmits on Internet will be in the form of group of characters. Such group of characters are called as 'String'. JavaSoft people have created a class separately with the name of 'String' in java.lang package with all necessary methods to work with String.           Even though, String class, it is used often in the form of a data type, as String s = "Java" ; Creating String:           There are 3 ways to create String in java.               • We can create a String just by assigning a group of characters to String type variable String s ; // Declare String type variable s = "Java" ; // Assign a group of charecters to it           Preceding two statements can be combined and written here, String s = "Java" ;    ...