Frequently Asked Java Program 27: Java Program to Find Occurrence of Any Char in a Given String Without Iterating

Problem Statement: Find occurrence of given char  (Ignore case)  in given string without iterating through string. Input – Make Selenium Easy Char – ‘M’ Output- Occurrence of M is 2. Problem Solution: We need to solve this problem without iterating through string in search of character. Its simple. Logic step by step: FInd the initial length

Read More

Frequently Asked Java Program 26: Java Program to Find Occurrence of Each Char in a Given String Without Using Collection

Problem Statement: Write a program to print occurrence of each character in given string without using Collection. Example:- Please enter the string to find occurrence of each char: Make Selenium Easy You entered: Make Selenium Easy Occurrence of M : 2 Occurrence of A : 2 Occurrence of K : 1 Occurrence of E :

Read More

Frequently Asked Java Program 25: Java Program to Convert a String Sentence in Camel Case

“CamelCase” is a naming convention in which words are joined together without any whitespace in between and each word starts with a capital letter which increase readability. It is mostly used to name variables and methods in programming languages. Example: MakeSeleniumEasy Problem Statement: Input: make selenium easy Output: MakeSeleniumEasy Convert first character of each word

Read More

Frequently Asked Java Program 24: Java Program to Capitalize First Character of Each Word in a String Sentence

Problem Statement: Input: make selenium easy Output: Make Selenium Easy Convert first character of each word into upper case. Solution: Logic: A sentence is a collection of words generally separated by a white space. We can extract words of given sentence using split method.  Now extract first character of first word and check if it

Read More

Frequently Asked Java Program 23: Java Program to Remove Extra WhiteSpace Between Words In Given String

Problem Statement: Remove extra white spaces between words. Only one white space is allowed between words. If more than one, remove it. If given string has leading or trailing white spaces, remove them as well. Do not use trim method. Write your own logic. Example: You entered with spaces: ”       Make     

Read More

Frequently Asked Java Program 22: Java Program to Trim Whitespace From String Without Using Trim Method

Hello Folks, This interview question was asked in Deloitte.  Write a java program to Trim a given string without using inbuilt trim() method of String Class in Java. “trim()” method of String class trims leading and trailing whitespace/s of given string. It does not remove whitespace between words. We need to write logic to do so.

Read More

Frequently Asked Java Program 21: Java Program to Find & Print All Special Characters with Their Positions in a String

This programming interview question was asked in Yodlee.  Problem: Write a Java program to find and print all special characters with their positions in a user input string. Example: Input string: Make%Selenium$Easy# Output: % at position 5. $ at position 14. # at position 19. Total special characters found:3 Solution: We will use regex to

Read More

Frequently Asked Java Program 19: Java Program to Reverse Position of Words in a String

Problem statement: Write a Java program to reverse position of words in given string i.e. word at first position in string should be at last position in string. Input String: You are awesome Output String: awesome are You Solution: It is a very easy program. You just need understanding of splitting a string, array and

Read More

Please wait...

Subscribe to new posts to become automation expert

Want to be notified when my new post is published? Get my posts in your inbox.