0% found this document useful (0 votes)
1 views6 pages

String_Programming_Java_Worksheet

Computer string program document
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views6 pages

String_Programming_Java_Worksheet

Computer string program document
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

String Programming Worksheet (2025 - 2026)

Q1. Write a program in Java to input a sentence and count the number of vowels in a sentence.

Sample Input: My name is Anand Shankar.

Sample Output: No of vowels = 7

Q2. Write a program in Java to replace a given character in a string.

Sample Input: My name is Anand Shankar.

Enter a character: n

Enter the character to be replaced: t

Sample Output: My tame is Atadt Shatkar.

Q3. Write a program in Java to input a sentence and delete a character next of the vowel.

Sample Input: KANPUR

Sample Output: KNPR

Q4. Write a program in Java to input a sentence and display the short form of it.

Sample Input: Defence Research Development Organization

Sample Output: DRDO

Q5. Write a program in Java to input a name and display the initials with the surname.

Sample Input: Anand Shankar Srivastava.

Sample Output: A.S.Srivastava

Q6. Write a program in Java to input a sentence and find and display the repeating alphabets in it.

Sample Input: rabbit has a good habbit

Sample Output: bb, oo, bb

Q7. Write a program in Java to accept an email address and print its user name, domain name and type of

website in separate line.

Sample Input: [email protected]

Sample Output: Username: abc1234

Domain Name: gmail

Domain Type: com

Q8. Write a program in Java to check whether the number is palindrome or not.

Sample Input: 12344321

Sample Output: Palindrome number

Q9. Write a program in Java to make the word as palindrome if it is not palindrome.

Sample Input: AMIT


Sample Output: AMITTIMA

Q10. Write a program in Java to input a name and print it in pattern.

Sample Input: AMIT

Sample Output:

AM

AMI

AMIT

Q11. Write a program in Java to print the ASCII values of the characters in a word.

Sample Input: ANAND

Sample Output: 65 78 65 78 69

Q12. Write a program in Java to accept a word and print the palindrome words in it.

Sample Input: MOM

Sample Output: Palindrome Word

Q13. Write a program in Java to replace vowel with next character.

Sample Input: AMIT KUMAR

Sample Output: BMIT KVMBS

Q14. Write a program in Java to check whether the word is unique or not. A word is considered as unique if it

does not have any repeating characters.

Sample Input: HISTORY

Sample Output: Unique word

Sample Input: WRITING

Sample Output: Not a Unique Word

Q15. Write a program in Java to accept a number and count its digit.

Sample Input: 123456789

Sample Output: 45

Q16. Write a program in Java to a decimal number and convert it into binary number.

Sample Input: 43

Sample Output: 101011

Q17. Write a program in Java to a binary number and convert it into decimal number.

Sample Input: 10101101

Sample Output: 173


Q18. Write a program in Java to count the digits in odd positions.

Sample Input: 54759856874

Sample Output: 38

Q19. Write a program in Java to count the digits in even and odd positions and give the difference.

Sample Input: 54759856874

Sample Output: 8

Q20. Write a program in Java to delete only odd digits.

Sample Input: 54759856874

Sample Output: 48684

Q21. Write a program in Java to display the piglatin word

Sample Input: Rohit

Sample Output: ohitRay

Q22. Write a program in Java to display only digits in a string.

Sample Input: My date of birth is 20 oct 2005

Sample Output: 20 2005

Q23. Write a program in Java to accept a string and print the first and the last letter of the words.

Sample Input: My name is amit kumar

Sample Output: My ne is at kr

Q24. Write a program in Java to accept a string and delete all the 'o' or 'O' character from the string.

Sample Input: Good proposal will be accepted:

Sample Output: Gd prpsal will be accepted.

Q25. Write a program in Java to accept a string and replace all the middle characters of the words with '*'.

Sample Input: My name is Amit Kumar.

Sample Output: My*name*is*A**t*K***r.

Q26. Write a program in Java to accept a word and display the characters in alphabetical order.

Sample Input: ANAND

Sample Output: AADNN

Q27. Write a program in Java to accept a string and display the highest frequency character.

Sample Input: my name is amit kumar

Sample Output: m

Q28. Write a program in Java to accept a string and display the capital letter vowel count.

Sample Input: My Name Is Amit Kumar


Sample Output: Capital letter Vowel Count = 1

Q29. Write a program in Java to accept a word and display unique alphabets in it.

Sample Input: applications

Sample Output: aplictons

Q30. Write a program in Java to accept a word and print vowel and consonant separately.

Sample Input: KANPUR

Sample Output: AU KNPR

Q31. Write a program in Java to accept a word and print the count of uppercase, lower case, digits and

symbols separately.

Sample Input: kAnPuR-280025

Sample Output:

Upper Case Letters = 2

Lower Case Letters = 4

Symbols = 1

Digits = 6

Q32. Write a program in Java to accept a word and print upper case letter and lower case separately.

Sample Input: kANpUr

Sample Output: ANU kpr

Q33. Write a program in Java to accept a word and replace all vowels with next vowels.

Sample Input: KANPUR

Sample Output: KENPAR

Q34. Write a program in Java to accept a string and print same vowel paring in it.

Sample Input: Good Colour

Sample Output: oo oo

Q35. Write a program in Java to accept a word and print the reverse of it.

Sample Input: KARAN

Sample Output: NARAK

Q36. Write a program in Java to accept a word and check if it is a super string or not. A String is a super

string if no. of capital and small letter is same.

Sample Input: kANpUr

Sample Output: It is super string

Q37. Write a program in Java to accept a word and replace and print all middle characters with #.
Sample Input: KANPUR

Sample Output: K###R

Q38. Write a program in Java to accept a word and print frequency of each character present in it.

Sample Input: ANAND

Sample Output: A = 2 N = 2 D = 1

Q39. Write a program in Java to accept a word and print all characters between first and last vowel.

Sample Input: UNDERSTANDING

Sample Output: NDERSTAND

Q40. Write a program in Java to accept a PAN card number and check its validity. A valid pan number has 5

alphabets, 4 digits and a character as combination.

Sample Input: BMKIJ9857R

Sample Output: VALID PAN

Q41. Write a program in Java to accept a IFSC code and check it validity. A IFSC has 4 alphabets, 7 digits as

combination.

Sample Input: UTIB0000883

Sample Output: Verified IFSC

Q42. Write a program in Java to accept a path of the file and print drive name, folder name/filename and

extension.

Sample Input: c:/Anand/abc.txt

Sample Output:

Drive Name: C:

Folder name: Anand

Filename: abc

Extension: txt

Q43. Write a program in Java to accept a email address and check it validity.

Sample Input: [email protected]

Sample Output: Valid email ID

Q44. Write a program in Java to accept a word and print highest frequency character present in it.

Sample Input: MALAYALAM

Sample Output: Highest Frequency Character is A

Q45. Write a program in Java to accept a word and print consecutive characters in it.

Sample Input: UNDERSTANDING


Sample Output: DE, RS, ST

Q46. Write a program in Java to accept a string and replace all characters with * and all digits with #.

Sample Input: ANAND123

Sample Output: *****###

Q47. Write a program in Java to accept 2 string and check they are anagram or not. A word is said anagram

where all characters are present in the second string.

Sample Input: FLOW WOLF

Sample Output: They are anagram words.

Q48. Write a program in Java to accept a word and print only repeated characters in the word.

Sample Input: MISSISSIPPI

Sample Output: I, S, P

Q49. Write a program in Java to accept a word and print their ASCII Values.

Sample Input: ABCDE

Sample Output: 65 66 67 68 69

Q50. Write a program in Java to accept a string and each word in different line.

Sample Input: RAVI AND KRISHNA

Sample Output:

RAVI

AND

KRISHNA

You might also like