Sail E0 Webinar

MCQs

Total Questions : 26 | Page 2 of 3 pages
Question 11. Which of these is an oncorrect statement?
  1.    String objects are immutable, they cannot be changed.
  2.    String object can point to some other reference of String variable.
  3.    StringBuffer class is used to store string in a buffer for later use.
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> StringBuffer class is used to store string in a buffer for later use.


StringBuffer class is used to create strings that can be modified after they are created.


Question 12. Which of these methods is used to compare a specific region inside a string with another specific region in another string?
  1.    regionMatch()
  2.    match()
  3.    RegionMatches()
  4.    regionMatches()
 Discuss Question
Answer: Option D. -> regionMatches()


regionMatches()


Question 13. Which of these method of class String is used to compare two String objects for their equality?
  1.    equals()
  2.    Equals()
  3.    isequal()
  4.    Isequal()
 Discuss Question
Answer: Option A. -> equals()


equals()


Question 14. Which of these method of class String is used to check weather a given object starts with a particular string literal?
  1.    startsWith()
  2.    endsWith()
  3.    Starts()
  4.    ends()
 Discuss Question
Answer: Option A. -> startsWith()


Method startsWith() of string class is used to check whether the String in question starts with a specified string. It is specialized form of method regionMatches()


Question 15. What is the value returned by unction compareTo() if the invoking string is less than the string compared?
  1.    zero
  2.    value less than zero
  3.    value greater than zero
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> value less than zero


compareTo() function returns zero when both the strings are equal, it returns a value less than zero if the invoking string is less than the other string being compared and value greater than zero when invoking string is greater than the string compared to.


Question 16. Which of these data type value is returned by equals() method of String class?
  1.    char
  2.    int
  3.    boolean
  4.    All of the mentioned
 Discuss Question
Answer: Option C. -> boolean


equals() method of string class returns boolean value true if both the string are equal and false if they are unequal.


Question 17. What is the value returned by function compareTo() if the invoking string is less than the string compared?
  1.    zero
  2.    value less than zero
  3.    value greater than zero
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> value less than zero


compareTo() function returns zero when both the strings are equal, it returns a value less than zero if the invoking string is less than the other string being compared and value greater than zero when invoking string is greater than the string compared to.


Question 18.

What will s2 contain after following lines of code?

 String s1 = "one;

 String s2 = s1.concat("two)

  1.    one
  2.    two
  3.    onetwo
  4.    twoone
 Discuss Question
Answer: Option C. -> onetwo


Two strings can be concatenated by using concat() method.


Question 19. Which of these method of class String is used to extract a substring from a String object?
  1.    substring()
  2.    Substring()
  3.    SubString()
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> substring()


substring()


Question 20. Which of these method of class String is used to remove leading and trailing whitespaces?
  1.    startsWith()
  2.    trim()
  3.    Trim()
  4.    doTrim()
 Discuss Question
Answer: Option B. -> trim()


trim()


Latest Videos

Latest Test Papers