Sail E0 Webinar

MCQs

Total Questions : 26 | Page 3 of 3 pages
Question 21. Which of the following statement is correct?
  1.    reverse() method reverses all characters.
  2.    reverseall() method reverses all characters.
  3.    replace() method replaces first occurrence of a character in invoking string with another character.
  4.    replace() method replaces last occurrence of a character in invoking string with another character
 Discuss Question
Answer: Option A. -> reverse() method reverses all characters.


reverse() method reverses all characters. It returns the reversed object on which it was called.


Question 22. Which of these method of class StringBuffer 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 23. Which of these method of class StringBuffer is used to reverse sequence of characters?
  1.    reverse()
  2.    reverseall()
  3.    Reverse()
  4.    reverseAll()
 Discuss Question
Answer: Option A. -> reverse()


reverse() method reverses all characters. It returns the reversed object on which it was called.


Question 24. Which of these method of class StringBuffer is used to get the length of sequence of characters?
  1.    length()
  2.    capacity()
  3.    Length()
  4.    Capacity()
 Discuss Question
Answer: Option A. -> length()


length()- returns the length of String the StringBuffer would create whereas capacity() returns total number of characters that can be supported before it is grown.


Question 25.

What will s2 contain after following lines of code?

 StringBuffer s1 = "one;

 StringBuffer s2 = s1.append("two)

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


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


Question 26. Which of the following are incorrect form of StringBuffer class constructor?
  1.    StringBuffer()
  2.    StringBuffer(int size)
  3.    StringBuffer(String str)
  4.    StringBuffer(int size , String str)
 Discuss Question
Answer: Option D. -> StringBuffer(int size , String str)


StringBuffer(int size , String str)


Latest Videos

Latest Test Papers