0% found this document useful (0 votes)
24 views1 page

String Manipulation Exercises in Java

The document describes a program that takes an array of strings as input, extracts the last character from each string, concatenates them to form a new string, and returns the new string. It provides sample input of 3 strings ("ab", "a", "abcd") and output of the concatenated last characters ("Bad"). It also describes a similar program to count the number of vowels in a given string, providing sample input of "avinash" and output of the vowel count (3).

Uploaded by

prasanna kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

String Manipulation Exercises in Java

The document describes a program that takes an array of strings as input, extracts the last character from each string, concatenates them to form a new string, and returns the new string. It provides sample input of 3 strings ("ab", "a", "abcd") and output of the concatenated last characters ("Bad"). It also describes a similar program to count the number of vowels in a given string, providing sample input of "avinash" and output of the vowel count (3).

Uploaded by

prasanna kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Concatenate Characters

Given an array of Strings, write a program to take the last character of each
string and make a new String by concatenating it.
Include a class UserMainCode with a static method �concatCharacter� that accepts a
String array as input and returns the new String.
Create a class Main which would get the String array as input and call the static
method concatCharacterpresent in the UserMainCode.
Input and Output Format:
The first line of the input consists of an integer n that corresponds to the number
of strings in the input string array.
The next n lines of the input consist of the strings in the input string array.
Output consists of a string.
Sample Input:
3
ab
a
abcd
Sample Output:
Bad

2. Count Vowels

Given a string input, write a program to find the total number of vowels in the
given string.

Include a class UserMainCode with a static method �countVowels� that accepts a


String argument and returns an int that corresponds to the total number of vowels
in the given string.

Create a class Main which would get the String as input and call the static method
countVowels present in the UserMainCode.

Input and Output Format:


Input consists of a string.
Output consists of an integer..

Sample Input:
avinash

Sample Output:
3

You might also like