Strings MCQ's
Strings MCQ's
a) String class
b) Object class
c) StringBuffered class
d) None of these
STRINGS
16. Which of these methods is used to compare a specific region inside a string with another
specific region in another string?
a) regionMatch()
b) match()
c) regionMatches()
d) RegionMatches()
STRINGS
17. Which of these method of class String is used to check weather a given object starts with a
particular string literal?
a) startsWith()
b) Starts()
c) endsWith()
d) ends()
STRINGS
18. What is the string contained in str after following lines of code? a) Hell
class Strings
{ b) ello
public static void main(String[] args){
c) Hel
StringBuffer str = new StringBuffer(“Hello”);
str.deleteCharAt(0); d) llo
}
}
STRINGS
19. Which of the following are incorrect form of StringBuffer class constructor?
a) StringBuffer()
b) StringBuffer(int size)
c) StringBuffer(String str)
d) StringBuffer(int size , String str)
STRINGS
20. String constant pool allocates its memory in
a) Stack
b) Heap
c) Data Segment
d) Register
STRINGS
21. To overcome immutable nature of string class we use
a) StringBuffer
b) StringBuilder
c) Both a and b
d) None of these
STRINGS
22. Which class will you recommend among String, StringBuffer and StringBuilder classes if I want
mutable and thread safe objects?
a) String
b) StringBuffer
c) StringBuilder
d) None of these