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

Frequently Asked Java Program 18: Java Program to Reverse Every Word of a String

Hello Programmers, “Java Program to Reverse Every Word of a String” is frequently asked programming interview questions to freshers and experienced. I will try here to explain logic in simple steps so that you do not need to remember lines of code. Just implement the logic and you can code it.  Problem statement: Original string     

Read More

Java Programs 16: Java Program to Find Length of String Without Using Length Method

Hello Programmers, An interview candidate was asked to write java code to find the length of given string WITHOUT USING LENGTH METHOD in Capgemini. In this post, I will find length of string without using Length method but using some other method. :-p There is another method in String class called lastIndexOf(). LastIndexOf() method: As

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.