Home / CSE MCQs / JAVA MCQs :: Strings - Java

CSE MCQs :: JAVA MCQs

  1. Which of the following statement is correct?
  2. A.
    reverse() method reverses all characters.
    B.
    reverseall() method reverses all characters.
    C.
    replace() method replaces first occurrence of a character in invoking string with another character.
    D.
    replace() method replaces last occurrence of a character in invoking string with another character

  3. Which of these method of class StringBuffer is used to extract a substring from a String object?
  4. A.
    substring()
    B.
    Substring()
    C.
    SubString()
    D.
    None of the mentioned

  5. What will s2 contain after following lines of code?

     StringBuffer s1 = "one;

     StringBuffer s2 = s1.append("two)

  6. A.
    one
    B.
    two
    C.
    onetwo
    D.
    twoone

  7. Which of these method of class StringBuffer is used to reverse sequence of characters?
  8. A.
    reverse()
    B.
    reverseall()
    C.
    Reverse()
    D.
    reverseAll()

  9. Which of these method of class StringBuffer is used to get the length of sequence of characters?
  10. A.
    length()
    B.
    capacity()
    C.
    Length()
    D.
    Capacity()

  11. Which of the following are incorrect form of StringBuffer class constructor?
  12. A.
    StringBuffer()
    B.
    StringBuffer(int size)
    C.
    StringBuffer(String str)
    D.
    StringBuffer(int size , String str)