Here are some commonly asked interview questions related to Java Strings:
- What is a String in Java and how is it different from a primitive data type like int or char?
- How do you create a String in Java?
- What is the difference between a string literal and a string object in Java?
- What is the significance of the String class in Java?
- What are some of the methods available in the String class in Java?
- Can you concatenate two strings in Java? How would you do it?
- What is string immutability in Java?
- How does the String Pool work in Java?
- How would you compare two strings in Java?
- Can you explain the use of the equals() and equalsIgnoreCase() methods in Java?
- How would you find the length of a string in Java?
- What is the difference between the length() method and the length property in Java?
- How would you reverse a string in Java?
- Can you explain the difference between the substring() and the substring() method in Java?
- What are some of the commonly used string manipulation techniques in Java?
- How would you find the first occurrence of a substring in a string in Java?
- Can you explain the use of the indexOf() and lastIndexOf() methods in Java?
- What is the difference between the trim() and the replace() methods in Java?
- Can you explain the use of the split() method in Java?
- How would you convert a string to uppercase or lowercase in Java?
- Can you explain the use of the toCharArray() method in Java?
- Can you explain the use of the valueOf() method in Java?
- How would you compare two strings without using the equals() method in Java?
- Can you explain the difference between a StringBuilder and a StringBuffer in Java?
- What is the use of the StringTokenizer class in Java?
- Can you explain the difference between the + and the concat() method for string concatenation in Java?
- How would you check if a string contains a certain character or substring in Java?
- Can you explain the use of the startsWith() and endsWith() methods in Java?
- How would you extract a portion of a string in Java?
- Can you explain the use of the compareTo() method in Java?
- How would you sort an array of strings in Java?
- Can you explain the difference between the == and the equals() method for string comparison in Java?
- How would you change the case of characters in a string in Java?
- Can you explain the use of the StringWriter and StringReader classes in Java?
- How would you find the number of occurrences of a substring in a string in Java?
- Can you explain the difference between the String and StringBuffer classes in Java?
- How would you replace a character in a string in Java?
- Can you explain the use of the StringJoiner class in Java?
- How would you check if a string is a palindrome in Java?
- Can you explain the difference between the substring() and the subSequence() methods in Java?
- How would you find the first non-repeated character in a string in Java?
- Can you explain the use of the format() method in Java?
- How would you remove duplicates from a string in Java?
- Can you explain the use of the CharSequence interface in Java?
- How would you find the longest common prefix of two strings in Java?
