Sail E0 Webinar

MCQs

Total Questions : 29 | Page 3 of 3 pages
Question 21.

Which of these method of class String is used to obtain length of String object?


  1.    get()
  2.    Sizeof()
  3.    lengthof()
  4.    length()
 Discuss Question
Answer: Option D. -> length()

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


Question 22.

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()

None.

Question 23.

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 24.

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()

None.



Question 25.

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


  1.    +
  2.    +=
  3.    &
  4.    ||
 Discuss Question
Answer: Option A. -> +

operator + is used to concatenate strings, Example String s = "i " + "like " + "java", String s contains 

"I like java".


Question 26.

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()

None.


Question 27.

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


  1.    java.util
  2.    java.lang
  3.    ArrayList
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> java.lang

None.


Question 28.

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()

 None.



Question 29.

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.

Latest Videos

Latest Test Papers