0% found this document useful (0 votes)
48 views

Java String Handling Practice Questions

Uploaded by

adarsh9eleven
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)
48 views

Java String Handling Practice Questions

Uploaded by

adarsh9eleven
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/ 1

Tutorial Questions

Topic - String Handling

1) Write a Java program which takes a sentence as string and returns a


sentence on which words are reversed in order, like if the input is "Java is
best programming language", the output should be "language
programming best is Java".
2) Write a Java program to implement an algorithm that will accept a string
of characters and should find the highest occurrence of the character and
display it. For example if input is "aaaaaaaaaaaaaaaaabbbbcddddeeeeee"
it should return "a".
3) Write a Java program to replace each substring of a given string that
matches the given regular expression with the given replacement. For
example, the sample string is "The quick brown fox jumps over the lazy
dog." In the above string, replace all the fox with cat.
4) Write a Java program to divide a string in n equal parts. For example,
the given string is: abcdefghijklmnopqrstuvwxy. The string divided into 5
parts and they are: abcde, fghij, klmno, pqrst, uvwxy.
5) Write a Java program to read two strings, append them together and
return the result. If the strings are different lengths, remove characters
from the beginning of longer string and make them equal length. For
example, the given strings is: Welcome and home. The new string is:
comehome.

You might also like