Module 4: String Programs

Java string manipulation programs covering reversal, searching, counting, validation, and transformations.

25 program solutions

Back to Topics

Program Solutions

1

Reverse String

Reverse a given string using a loop.

Beginner
View Solution
2

Check Palindrome String

Check whether a string is a palindrome.

Beginner
View Solution
3

Count Vowels

Count the number of vowels in a string.

Beginner
View Solution
4

Count Consonants

Count the number of consonants in a string.

Beginner
View Solution
5

Count Words

Count the number of words in a sentence.

Beginner
View Solution
6

Remove Whitespace

Remove all whitespace characters from a string.

Beginner
View Solution
7

Remove Duplicate Characters

Remove duplicate characters from a string, keeping first occurrences.

Intermediate
View Solution
8

Anagram Check

Check whether two strings are anagrams of each other.

Intermediate
View Solution
9

String Rotation

Check if one string is rotation of another.

Intermediate
View Solution
10

Frequency of Characters

Count frequency of each character in a string.

Intermediate
View Solution
11

Longest Word

Find the longest word in a sentence.

Beginner
View Solution
12

Shortest Word

Find the shortest word in a sentence.

Beginner
View Solution
13

Replace Substring

Replace all occurrences of a substring in a string.

Beginner
View Solution
14

Reverse Words in Sentence

Reverse the order of words in a sentence.

Beginner
View Solution
15

Sort Characters

Sort characters of a string in ascending order.

Beginner
View Solution
16

Convert to Title Case

Convert a sentence to title case (first letter of each word uppercase).

Beginner
View Solution
17

Count Uppercase Letters

Count number of uppercase letters in a string.

Beginner
View Solution
18

Count Lowercase Letters

Count number of lowercase letters in a string.

Beginner
View Solution
19

Extract Numbers

Extract all numbers (digits) from a string.

Beginner
View Solution
20

Validate Email (Regex)

Validate email format using a simple regex.

Intermediate
View Solution
21

Validate Password

Check if a password meets basic strength rules using regex.

Intermediate
View Solution
22

Check Pangram

Check whether a sentence is a pangram (contains all letters A–Z).

Intermediate
View Solution
23

Split & Join Strings

Split a sentence into words and then join them with a different delimiter.

Beginner
View Solution
24

String Compression

Compress a string as character followed by count (basic run-length encoding).

Intermediate
View Solution
25

String Permutations

Generate all permutations of a string using recursion.

Advanced
View Solution