Strings
100 Java String Programming Questions
A clean list of 100 string-focused programming questions in Java — arranged Basic → Intermediate → Advanced. Copy this HTML into your Blogger post's HTML editor and tweak the CSS variables at the top to change colors and fonts.
- Write a program to find the length of a string.
- Write a program to print each character of a string.
- Write a program to reverse a string.
- Write a program to check if a string is a palindrome.
- Write a program to count vowels in a string.
- Write a program to count consonants in a string.
- Write a program to count digits in a string.
- Write a program to count spaces in a string.
- Write a program to count special characters in a string.
- Write a program to convert a string to uppercase.
- Write a program to convert a string to lowercase.
- Write a program to convert uppercase letters to lowercase and vice versa.
- Write a program to remove vowels from a string.
- Write a program to remove spaces from a string.
- Write a program to remove all digits from a string.
- Write a program to remove all special characters from a string.
- Write a program to replace spaces with underscores.
- Write a program to replace a character in a string.
- Write a program to check if two strings are equal.
- Write a program to check if two strings are equal ignoring case.
- Write a program to compare two strings lexicographically.
- Write a program to concatenate two strings.
- Write a program to check if a string contains a given substring.
- Write a program to find the index of the first occurrence of a character.
- Write a program to find the index of the last occurrence of a character.
- Write a program to extract a substring from a string.
- Write a program to split a string into words.
- Write a program to find the first character of a string.
- Write a program to find the last character of a string.
- Write a program to count the number of words in a string.
- Write a program to count the frequency of a given character in a string.
- Write a program to count the frequency of each character in a string.
- Write a program to remove duplicate characters from a string.
- Write a program to check if a string starts with a given prefix.
- Write a program to check if a string ends with a given suffix.
- Write a program to trim leading and trailing spaces from a string.
- Write a program to reverse each word in a string.
- Write a program to capitalize the first letter of each word in a string.
- Write a program to swap the first and last character of a string.
- Write a program to check if a string is empty or not.
- Write a program to count the number of uppercase and lowercase letters in a string.
- Write a program to check if a string contains only digits.
- Write a program to check if a string contains only alphabets.
- Write a program to check if a string contains only alphanumeric characters.
- Write a program to check if a string is a valid identifier.
- Write a program to remove consecutive duplicate characters.
- Write a program to find the longest word in a string.
- Write a program to find the shortest word in a string.
- Write a program to sort characters of a string alphabetically.
- Write a program to sort words of a string alphabetically.
- Write a program to find the longest palindrome word in a string.
- Write a program to reverse the order of words in a string.
- Write a program to count the frequency of words in a string.
- Write a program to check if two strings are anagrams.
- Write a program to check if two strings are rotations of each other.
- Write a program to check if a string is a pangram.
- Write a program to check if a string is an isogram (no repeating letters).
- Write a program to check if a string is a heterogram (no duplicate words).
- Write a program to print all substrings of a string.
- Write a program to print all permutations of a string.
- Write a program to print all combinations of characters in a string.
- Write a program to find the first non-repeated character in a string.
- Write a program to find the first repeated character in a string.
- Write a program to check if a string has balanced parentheses.
- Write a program to check if a string has balanced brackets of all types.
- Write a program to count the occurrences of each word in a string.
- Write a program to remove duplicate words from a string.
- Write a program to replace all occurrences of a word in a string.
- Write a program to rotate a string to the left by n positions.
- Write a program to rotate a string to the right by n positions.
- Write a program to check if a string is a substring of another string without using built-in methods.
- Write a program to reverse a string without using inbuilt functions.
- Write a program to check if a string contains only unique characters.
- Write a program to check if one string can be formed from another by deleting characters.
- Write a program to find the lexicographically smallest and largest substring of a given length.
- Write a program to find the longest substring without repeating characters.
- Write a program to find the longest palindromic substring.
- Write a program to find the longest common prefix among strings.
- Write a program to find the longest common suffix among strings.
- Write a program to find the longest common substring between two strings.
- Write a program to find the longest common subsequence between two strings.
- Write a program to implement string matching using brute force.
- Write a program to implement string matching using the KMP algorithm.
- Write a program to implement string matching using the Rabin-Karp algorithm.
- Write a program to implement pattern matching with wildcards ('*', '?').
- Write a program to check if one string is a subsequence of another.
- Write a program to check if one string is a substring of another using recursion.
- Write a program to find the edit distance between two strings.
- Write a program to check if two strings are one edit distance apart.
- Write a program to find the minimum number of insertions to make a string palindrome.
- Write a program to check if two strings are scrambled versions of each other.
- Write a program to group anagrams from a list of strings.
- Write a program to check if a string can be divided into equal parts.
- Write a program to find the smallest window in a string containing all characters of another string.
- Write a program to check if a string is a valid shuffle of two other strings.
- Write a program to compress a string (e.g., aaabb → a3b2).
- Write a program to decompress a string (e.g., a3b2 → aaabb).
- Write a program to implement run-length encoding of a string.
- Write a program to count distinct substrings of a string.
- Write a program to find the lexicographically next permutation of a string.
A. Basic String Programs (1–40)
B. Intermediate String Programs (41–75)
C. Advanced String Programs (76–100)
Comments
Post a Comment