top of page

String Programming Questions (Java).

Strings in Java is one the widest topic that you will go through. If you want to get an idea of all of the classes and methods which are related to string go here. We are going to cover the most important ones that you will use.


Let's just refresh our concept on String:--


Now in simpler terms String is a combination of characters. Now the characters can be alphabetical, numeric, or symbols. For example, if I write "Hi" then it is a string which is a combination of alphabetical characters which are H and I, similarly, the string can be "hi34", "1345", "@$khf232".

To define a string in Java we use Keyword String.

char[] ch={'j','a','v','a'};  
String s=new String(ch); 

The above 2 lines code is the same as:-

String s="java";  

Questions:-


Write Java Programs for the given scenario:-

  • returns char value for the particular index

  • returns string length

  • returns a formatted string.

  • returns a formatted string with given locale.

  • returns substring for given begin index.

  • returns substring for given begin index and end index.

  • returns true or false after matching the sequence of char value.

  • returns a joined string.

  • returns a joined string.

  • checks the equality of string with the given object.

  • checks if a string is empty.

  • concatenates the specified string.

  • replaces all occurrences of the specified char value.

  • replaces all occurrences of the specified CharSequence.

  • compares another string. It doesn't check case.

  • returns a split string matching regex.

  • returns a split string matching regex and limit.

  • returns an interned string.

  • returns the specified char value index.

  • returns the specified char value index starting with given index.

  • returns the specified substring index.

  • returns the specified substring index starting with given index.

  • returns a string in lowercase.

  • returns a string in lowercase using specified locale.

  • returns a string in uppercase.

  • returns a string in uppercase using specified locale.

  • removes the beginning and ending spaces of this string.

  • converts given type into a string. It is an overloaded method.



Write a Java Program to perform the following:-

  • to reverse a string.

  • to check if the string is a palindrome

  • to count the number of words in a string

  • to number of characters in a string

  • to find out the first non-repeated string character.

  • to test if a given string contains the specified sequence of char values

  • to compare a given string to the specified character sequence.

  • to check whether a given string ends with the contents of another string

  • to print current date and time in the specified format

  • to get the index of all the characters of the alphabet.

  • to check whether a given string starts with the contents of another string

  • to get a substring of a given string between two specified positions

  • to convert all the characters in a string to lowercase.

  • to convert all the characters in a string to uppercase.

  • to remove a specified character from a given string

  • to sort in ascending and descending order by length of the given array of strings

  • to count the occurrences of a given string in another given string.

  • to concatenate a given string with itself of a given number of times

  • to test if a given string contains only digits. Return true or false



More questions will be added soon. Keep practicing.


Share with your friends and family.


Need help !!!! Contact us...


Recent Posts

See All
bottom of page