Strings


  1. What is the output of this program?

    public class Result
    {
    public static void main(String args[])
    {
    String str1 = "Interview";
    String str2 = str1 + " Mania";
    System.out.println(str2);
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Interview Mania


  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. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

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



  1. Which of the following statement is correct?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    replace() method replaces all occurrences of one character in invoking string with another character.


  1. What is the value returned by function compareTo() if the invoking string is greater than the string compared?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    value greater than zero



  1. Which of these method of class String is used to remove leading and trailing whitespaces?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    trim()