Home » JAVA Programming » Strings » Question
  1. What is the output of this program?

    public class Result
    {
    public static void main(String args[])
    {
    String str0 = " Interview mania ";
    String str1 = str0.trim();
    System.out.println("\""+str1+"\"");
    }
    }
    1. " Interview mania "
    2. "Interview mania"
    3. Interview mania
    4. Interviewmania
    5. None of these
Correct Option: B

trim() method is used to remove leading and trailing whitespaces in a string.



Your comments will be displayed only after manual approval.