InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which of this method of class StringBuffer is used to get the length of the sequence of characters?(a) length()(b) capacity()(c) Length()(d) Capacity()I have been asked this question by my college director while I was bunking the class.The origin of the question is StringBuffer Methods in portion String Handling of Java |
|
Answer» The CORRECT choice is (a) length() |
|
| 2. |
Which of this method of class StringBuffer is used to reverse sequence of characters?(a) reverse()(b) reverseall()(c) Reverse()(d) reverseAll()I got this question in final exam.This question is from StringBuffer Methods in portion String Handling of Java |
|
Answer» The correct answer is (a) reverse() |
|
| 3. |
Which of these methods of class StringBuffer is used to extract a substring from a String object?(a) substring()(b) Substring()(c) SubString()(d) None of the mentionedThe question was asked in an online quiz.Enquiry is from StringBuffer Methods in section String Handling of Java |
|
Answer» Right choice is (a) SUBSTRING() |
|
| 4. |
What is the value returned by function compareTo() if the invoking string is greater than the string compared?(a) zero(b) value less than zero(c) value greater than zero(d) none of the mentionedI have been asked this question in an internship interview.Asked question is from Searching & Modifying a String in portion String Handling of Java |
|
Answer» The CORRECT choice is (C) value greater than zero |
|
| 5. |
Which of this method of class String is used to extract a substring from a String object?(a) substring()(b) Substring()(c) SubString()(d) None of the mentionedI have been asked this question by my college director while I was bunking the class.Question is from Searching & Modifying a String topic in section String Handling of Java |
|
Answer» Correct answer is (a) SUBSTRING() |
|
| 6. |
What is the value returned by function compareTo() if the invoking string is less than the string compared?(a) zero(b) value less than zero(c) value greater than zero(d) none of the mentionedI have been asked this question during an interview for a job.My enquiry is from String Comparison topic in chapter String Handling of Java |
|
Answer» CORRECT answer is (b) VALUE less than zero Explanation: compareTo() function returns zero when both the strings are equal, it returns a value less than zero if the INVOKING string is less than the other string being COMPARED and value GREATER than zero when invoking string is greater than the string compared to. |
|
| 7. |
Which of these method of class String is used to remove leading and trailing whitespaces?(a) startsWith()(b) trim()(c) Trim()(d) doTrim()This question was addressed to me during an online interview.Asked question is from Searching & Modifying a String in section String Handling of Java |
|
Answer» The CORRECT ANSWER is (b) trim() |
|
| 8. |
Which of these methods of class String is used to check whether a given object starts with a particular string literal?(a) startsWith()(b) endsWith()(c) Starts()(d) ends()This question was posed to me by my college director while I was bunking the class.The origin of the question is String Comparison topic in division String Handling of Java |
|
Answer» Right answer is (a) startsWith() |
|
| 9. |
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()I had been asked this question by my school principal while I was bunking the class.I'm obligated to ask this question of String Comparison topic in portion String Handling of Java |
|
Answer» CORRECT OPTION is (d) regionMatches() To ELABORATE: NONE. |
|
| 10. |
Which of these method of class String is used to compare two String objects for their equality?(a) equals()(b) Equals()(c) isequal()(d) Isequal()The question was posed to me in my homework.My doubt is from String Comparison topic in division String Handling of Java |
|
Answer» CORRECT OPTION is (a) EQUALS() To EXPLAIN: NONE. |
|
| 11. |
Which of these constructors is used to create an empty String object?(a) String()(b) String(void)(c) String(0)(d) None of the mentionedThe question was posed to me in semester exam.I want to ask this question from String Handling Basics in section String Handling of Java |
| Answer» | |
| 12. |
Which of these method of class String is used to extract a single character from a String object?(a) CHARAT()(b) chatat()(c) charAt()(d) ChatAt()I have been asked this question during an internship interview.Origin of the question is String Handling Basics topic in section String Handling of Java |
|
Answer» Correct choice is (C) charAt() |
|
| 13. |
Which of this method of class String is used to obtain a length of String object?(a) get()(b) Sizeof()(c) lengthof()(d) length()I got this question in unit test.Query is from String Handling Basics in portion String Handling of Java |
|
Answer» The correct CHOICE is (d) length() |
|
| 14. |
Which of these class is superclass of String and StringBuffer class?(a) java.util(b) java.lang(c) ArrayList(d) None of the mentionedThis question was posed to me during an online interview.The origin of the question is String Handling Basics in chapter String Handling of Java |
| Answer» | |
| 15. |
Which of these operators can be used to concatenate two or more String objects?(a) +(b) +=(c) &(d) ||I got this question during an online interview.My question comes from String Handling Basics topic in section String Handling of Java |
|
Answer» RIGHT choice is (a) + For explanation I WOULD say: Operator + is used to concatenate strings, EXAMPLE String s = “i ” + “like ” + “JAVA”; String s CONTAINS “I like java”. |
|