Thursday, 13 July 2017

Java String FAQs in java ~ foundjava

Java String FAQs or Interview Questions

A list of top Java String FAQs (Frequently Asked Questions) or interview questions are given below. These questions can be asked by the interviewer.

1) How many objects will be created in the following code?

String s1="javatpoint";
String s2="javatpoint";
Answer: Only one.

2) What is the difference between equals() method and == operator?

The equals() method matches content of the strings whereas == operator matches object or reference of the strings.

3) Is String class final?

Answer: Yes.

4) How to reverse String in java?

Input:
this is javatpoint
Output:
tnioptavaj si siht

5) How to check Palindrome String in java?

Input:
nitin
Output:
true
Input:
jatin
Output:
false

6) Write a java program to capitalize each word in string?

Input:
this is javatpoint
Output:
This Is Javatpoint

7) Write a java program to reverse each word in string?

Input:
this is javatpoint
Output:
siht si tnioptavaj

8) Write a java program to tOGGLE each word in string?

Input:
this is javatpoint
Output:
tHIS iS jAVATPOINT

9) Write a java program reverse tOGGLE each word in string?

Input:
this is javatpoint
Output:
sIHT sI tNIOPTAVAJ

10) What is the difference between String and StringBuffer in java?

11) What is the difference between StringBuffer and StringBuilder in java?

12) What does intern() method in java?

13) How to convert String to int in java?

14) How to convert int to String in java?

15) How to convert String to Date in java?

16) How to Optimize Java String Creation?

17) Java Program to check whether two Strings are anagram or not

18) Java program to find the percentage of uppercase, lowercase, digits and special characters in a String

19) How to convert String to Integer and Integer to String in Java

20) Java Program to find duplicate characters in a String

21) Java Program to prove that strings are immutable in java

22) Java Program to remove all white spaces from a String

23) Java Program to check whether one String is a rotation of another

24) Java Program to count the number of words in a String

25) Java Program to reverse a given String with preserving the position of space

26) How to swap two String variables without third variable

27) How to remove a particular character from a String

10 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Your blog has one of the best explanation on java programs with appropriate links. Thanks for sharing.

    Cheers,
    https://www.flowerbrackets.com/java-program-check-whether-string-palindrome/

    ReplyDelete
  6. Nice explanation on java string faqs with examples. Thanks for sharing.

    Cheers,
    https://www.flowerbrackets.com/java-remove-character-from-string/

    ReplyDelete
  7. Your blog has content with all useful links that are useful in interview. Thanks

    Cheers,
    https://www.flowerbrackets.com/reverse-string-in-java/

    ReplyDelete
  8. Best faq on java with appropriate links. Thanks for sharing.

    Cheers,
    https://www.flowerbrackets.com/java-convert-string-to-date/

    ReplyDelete
  9. Well explained string operation .
    there are good String program collection visit Top String program

    ReplyDelete
  10. Best java string faqs. Thanks for sharing.
    https://www.flowerbrackets.com/reverse-string-in-java/

    ReplyDelete