Strings


  1. Which of these class is superclass of String and StringBuffer class?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    java.lang


  1. Which of this method of class String is used to obtain a length of String object?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Method length() of string class is used to get the length of the object which invoked method length().



  1. Which of these operators can be used to concatenate two or more String objects?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Operator + is used to concatenate strings, Example String s = “i ” + “like ” + “java”; String s contains “I like java”.


  1. Which of these method of class String is used to extract a single character from a String object?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    charAt()



  1. What is the output of this program?

    public class Result
    {
    public static void main(String[]args)
    {
    String[] array = { "for", "tea", "too" };
    String num= (array.length > 2) ? array[2]: null;
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The value at the 0th position will be assigned to the variable num.