Show
DownloadApp
Home » JAVA Programming » Strings » Question
length()
Java MCQs on StringBuffer class of Java Programming Language. 1. Which of these class is used to create an object whose character sequence is mutable?a) String()b) StringBuffer()c) String() & StringBuffer()d) None of the mentioned
Answer: b 2. Which of this method of class StringBuffer is used to concatenate the string representation to the end of invoking string?a) concat()b) append()c) join()d) concatenate()
Answer: b 3. Which of these method of class StringBuffer is used to find the length of current character sequence?a) length()b) Length()c) capacity()d) Capacity()
Answer: a 4. What is the string contained in s after following lines of Java code?
StringBuffer s new StringBuffer("Hello"); s.deleteCharAt(0); a) Hellb) elloc) Held) llo
Answer: b 5. Which of the following statement is correct?a) reverse() method reverses all charactersb) reverseall() method reverses all charactersc) replace() method replaces first occurrence of a character in invoking string with another characterd) replace() method replaces last occurrence of a character in invoking string with another character
Answer: a 6. What will be the output of the following Java program?
a) 6 4 6 9b) 5 4 5 9c) 7 8 8 9d) 1 14 8 15
Answer: d Clarification: indexof(‘c’) and lastIndexof(‘c’) are pre defined function which are used to get the index of first and last occurrence of the character pointed by c in the given array. Output:
$ javac output.java $ java output 1 14 8 15
Here you can find Strings Questions and Answers. Why Strings Questions and Answers Required?In this Strings Questions and Answers section you can learn and practice Strings Questions and Answers to improve your skills in order to face technical inerview conducted by organisations. By Practicing these interview questions, you can easily crack any Exams interview. Where can I get Strings Questions and Answers?AllIndiaExams provides you lots Strings Questions and Answers with proper explanation. Fully solved examples with detailed answer description. All students, freshers can download Strings Questions and Answers as PDF files and eBooks. How to solve these Strings Questions and Answers?You no need to worry, we have given lots of Strings Questions and Answers and also we have provided lots of FAQ's to quickly answer the questions in the Competitive Exams interview. Strings Questions and Answers1. Which of these class is superclass of String and StringBuffer class? Strings Questions and Answers2. Which of these operators can be used to concatenate two or more String objects? Strings Questions and Answers3. Which of these method of class String is used to obtain length of String object? Strings Questions and Answers4. Which of these method of class String is used to extract a single character from a String object? Strings Questions and Answers5. Which of these constructors is used to create an empty String object? Strings Questions and Answers6. Which of these is an oncorrect statement? Strings Questions and Answers7. Which of these method of class String is used to compare two String objects for their equality? Strings Questions and Answers8. Which of these methods is used to compare a specific region inside a string with another specific region in another string? Strings Questions and Answers9. Which of these method of class String is used to check weather a given object starts with a particular string literal? Strings Questions and Answers10. What is the value returned by function compare to() if the invoking string is less than the string compared? - Page 4
|