Strings

100 Java String Programming Questions

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.

    A. Basic String Programs (1–40)
    1. Write a program to find the length of a string.
    2. Write a program to print each character of a string.
    3. Write a program to reverse a string.
    4. Write a program to check if a string is a palindrome.
    5. Write a program to count vowels in a string.
    6. Write a program to count consonants in a string.
    7. Write a program to count digits in a string.
    8. Write a program to count spaces in a string.
    9. Write a program to count special characters in a string.
    10. Write a program to convert a string to uppercase.
    11. Write a program to convert a string to lowercase.
    12. Write a program to convert uppercase letters to lowercase and vice versa.
    13. Write a program to remove vowels from a string.
    14. Write a program to remove spaces from a string.
    15. Write a program to remove all digits from a string.
    16. Write a program to remove all special characters from a string.
    17. Write a program to replace spaces with underscores.
    18. Write a program to replace a character in a string.
    19. Write a program to check if two strings are equal.
    20. Write a program to check if two strings are equal ignoring case.
    21. Write a program to compare two strings lexicographically.
    22. Write a program to concatenate two strings.
    23. Write a program to check if a string contains a given substring.
    24. Write a program to find the index of the first occurrence of a character.
    25. Write a program to find the index of the last occurrence of a character.
    26. Write a program to extract a substring from a string.
    27. Write a program to split a string into words.
    28. Write a program to find the first character of a string.
    29. Write a program to find the last character of a string.
    30. Write a program to count the number of words in a string.
    31. Write a program to count the frequency of a given character in a string.
    32. Write a program to count the frequency of each character in a string.
    33. Write a program to remove duplicate characters from a string.
    34. Write a program to check if a string starts with a given prefix.
    35. Write a program to check if a string ends with a given suffix.
    36. Write a program to trim leading and trailing spaces from a string.
    37. Write a program to reverse each word in a string.
    38. Write a program to capitalize the first letter of each word in a string.
    39. Write a program to swap the first and last character of a string.
    40. Write a program to check if a string is empty or not.
    B. Intermediate String Programs (41–75)
    1. Write a program to count the number of uppercase and lowercase letters in a string.
    2. Write a program to check if a string contains only digits.
    3. Write a program to check if a string contains only alphabets.
    4. Write a program to check if a string contains only alphanumeric characters.
    5. Write a program to check if a string is a valid identifier.
    6. Write a program to remove consecutive duplicate characters.
    7. Write a program to find the longest word in a string.
    8. Write a program to find the shortest word in a string.
    9. Write a program to sort characters of a string alphabetically.
    10. Write a program to sort words of a string alphabetically.
    11. Write a program to find the longest palindrome word in a string.
    12. Write a program to reverse the order of words in a string.
    13. Write a program to count the frequency of words in a string.
    14. Write a program to check if two strings are anagrams.
    15. Write a program to check if two strings are rotations of each other.
    16. Write a program to check if a string is a pangram.
    17. Write a program to check if a string is an isogram (no repeating letters).
    18. Write a program to check if a string is a heterogram (no duplicate words).
    19. Write a program to print all substrings of a string.
    20. Write a program to print all permutations of a string.
    21. Write a program to print all combinations of characters in a string.
    22. Write a program to find the first non-repeated character in a string.
    23. Write a program to find the first repeated character in a string.
    24. Write a program to check if a string has balanced parentheses.
    25. Write a program to check if a string has balanced brackets of all types.
    26. Write a program to count the occurrences of each word in a string.
    27. Write a program to remove duplicate words from a string.
    28. Write a program to replace all occurrences of a word in a string.
    29. Write a program to rotate a string to the left by n positions.
    30. Write a program to rotate a string to the right by n positions.
    31. Write a program to check if a string is a substring of another string without using built-in methods.
    32. Write a program to reverse a string without using inbuilt functions.
    33. Write a program to check if a string contains only unique characters.
    34. Write a program to check if one string can be formed from another by deleting characters.
    35. Write a program to find the lexicographically smallest and largest substring of a given length.
    C. Advanced String Programs (76–100)
    1. Write a program to find the longest substring without repeating characters.
    2. Write a program to find the longest palindromic substring.
    3. Write a program to find the longest common prefix among strings.
    4. Write a program to find the longest common suffix among strings.
    5. Write a program to find the longest common substring between two strings.
    6. Write a program to find the longest common subsequence between two strings.
    7. Write a program to implement string matching using brute force.
    8. Write a program to implement string matching using the KMP algorithm.
    9. Write a program to implement string matching using the Rabin-Karp algorithm.
    10. Write a program to implement pattern matching with wildcards ('*', '?').
    11. Write a program to check if one string is a subsequence of another.
    12. Write a program to check if one string is a substring of another using recursion.
    13. Write a program to find the edit distance between two strings.
    14. Write a program to check if two strings are one edit distance apart.
    15. Write a program to find the minimum number of insertions to make a string palindrome.
    16. Write a program to check if two strings are scrambled versions of each other.
    17. Write a program to group anagrams from a list of strings.
    18. Write a program to check if a string can be divided into equal parts.
    19. Write a program to find the smallest window in a string containing all characters of another string.
    20. Write a program to check if a string is a valid shuffle of two other strings.
    21. Write a program to compress a string (e.g., aaabb → a3b2).
    22. Write a program to decompress a string (e.g., a3b2 → aaabb).
    23. Write a program to implement run-length encoding of a string.
    24. Write a program to count distinct substrings of a string.
    25. Write a program to find the lexicographically next permutation of a string.

    Tip: To change colors or font, edit the CSS variables at the top of this document (inside the <style> block). Copy the entire HTML and paste into your Blogger post in HTML mode.

    /* Example: to change accent color to purple, set --accent: #7c3aed; */

Comments

Popular posts from this blog

Arrays