Functions of the String Class

Java : Functions of the String Class Program List




Program [1]

Java program to enter a sentence and print the words which starting with a vowel


View Solution


Program [2]

Write a Java Program to Swap first and last character of each words in a Sentence .

Example:

Input: infomax computer academy

Output: xnfomai romputec ycadema



View Solution


Program [3]

Java program to remove duplicate character from string

Sample:

Input: infomaxcomputeracademy

Output:  infomaxcputerdy


View Solution


Program [4]

java to swap first character of each word with next character


View Solution


Program [5]

Write a Java Program to check input string is Palindrome or Not.

Sample 1:

Input: nitin

Output: Entered string is a palindrome.


Sample 2:

Input: infomax

Output: Entered string is not a palindrome.



View Solution


Program [6]

Write a Java program to from a new word by extracting the first letter of each word in the entered sentence.


View Solution


Program [7]

Write a Program to convert first letter of each word in a sentence to uppercase and the remaining letters to lowercase.

Sample:

Input: InfoMax ComuTar aCadeMy

Output: Infomax Comutar Academy


View Solution


Program [8]

Pangram :- If a string contains every letter of the English alphabet i.e all 26 alphabets then the string is known as Pangram.

For Example :-

String1 = The quick brown fox jumps over the lazy dog

So as we can see that the given strings contains all letters of English alphabet therefore the string is Pangram.


View Solution


Program [9]

The potential of a word is found by adding the ASCII value of the alphabets.

(ASCII values of A to Z are 65 to 90).

Example: BALL

Potential = 66 + 65 + 76 + 76 = 283

Write a program to accept a sentence which may be terminated by either “ . ” , “ ? ” or “ ! ” only. The words of sentence are separated by single blank space and are in UPPER CASE. Decode the words according to their potential and arrange them in ascending order of their potential strength.

Test your program with the following data and some random data:

Example 1:

INPUT: HOW DO YOU DO?

OUTPUT: HOW = 238

DO = 147

YOU = 253

DO = 147

DO DO HOW YOU

Example 2:

INPUT: LOOK BEFORE YOU LEAP.

OUTPUT: LOOK = 309

BEFORE = 435

YOU = 253

LEAP = 290

YOU LEAP LOOK BEFORE

Example 3:

INPUT: HOW ARE YOU#

OUTPUT: INVALID INPUT


View Solution


Program [10]

Write a program to input a string in uppercase and print the frequency of each character.

Example:

INPUT : COMPUTER HARDWARE

OUTPUT:

CHARACTER FREQUENCY

A 2

C 1

D 1

E 2

H 1

M 1

O 1

P 1

R 3

T 1

U 1

W 1



View Solution


Program [11]

Write a program to accept a string. Convert the string to uppercase. Count and output the number of double letter sequences that exist in the string.


Example:


Input : SHE WAS FEEDING THE LITTLE RABBIT WITH AN APPLLE

Output: 4


View Solution


Program [12]

Write a program to assign a full path and file name as given below. Using library functions, extract and output the file path, file name and file extension separately as shown.

Input C:\Users\admin\Pictures\flower.jpg
Output Path: C:\Users\admin\Pictures\

File name: flower

Extension: jpg


View Solution


Program [13]

Design a program which accepts your date of birth in dd mm yyyy format. Check whether the date entered is valid or not. If it is valid, display “VALID DATE”, also compute and display the day number of the year for the date of birth. If it is invalid, display “INVALID DATE” and then terminate the program.

Test your program for the given sample data and some random data.

Example 1 :

INPUT: Enter your date of birth in dd mm yyyy format

05

01

2010


OUTPUT: VALID DATE 5

Example 2 :


INPUT: Enter your date of birth in dd mm yyyy format 03

04

2010


OUTPUT: VALID DATE

93

Example 3 :


INPUT: Enter your date of birth in dd mm yyyy format 34

06

2010


OUTPUT: INVALID DATE



View Solution


Program [14]

A Palindrome is a word that may be read the same way in either direction.

Accept a sentence in UPPER CASE which is terminated by either ” . “, ” ? ” or ” ! “. Each word of the sentence is separated by a single blank space.

Perform the following tasks:

(a) Display the count of palindromic words in the sentence.

(b) Display the palindromic words in the sentence. Example of palindromic words:

MADAM, ARORA, NOON

Test your program with the sample data and some random data:

Example 1

INPUT : MOM AND DAD ARE COMING AT NOON.

OUTPUT : MOM DAD NOON

NUMBER OF PALINDROMIC WORDS : 3

Example 2

INPUT : NITIN ARORA USES LIRIL SOAP.

OUTPUT : NITIN ARORA LIRIL

NUMBER OF PALINDROMIC WORDS : 3

Example 3

INPUT : HOW ARE YOU?

OUTPUT : NO PALINDROMIC WORDS



View Solution


Program [15]

Write a program to accept a sentence which may  be  terminated  by either  '.' or  '?' only. The  words are to be separated by a single blank space. Print an error message if the input does not terminate with '.' or '?'. You can assume that  no  word  in  the  sentence  exceeds  15  characters, so that you get a proper formatted output.

Perform the following tasks:

(i) Convert the first letter of each word to uppercase.

(ii) Find the number  of  vowels  and  consonants  in  each  word  and  display  them  with proper headings along with the words.

Test your program with the following inputs.

Example 1

INPUT : Intelligence plus character is education.

OUTPUT : Intelligence Plus Character Is Education


Word Vowels Consonants

Intelligence            5 7

Plus            1 3

Character    3 6

Is   1 1

Education  5 4


Example 2


INPUT : God is great.

OUTPUT : God Is Great


Word Vowels Consonants

God 1 2

Is 1 1

Great 2 3


Example 3


INPUT: All the best!

OUTPUT: Invalid Input.



View Solution


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad