adplus-dvertising

Welcome to the String Handling MCQs Page

Dive deep into the fascinating world of String Handling with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of String Handling, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of String Handling, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through String Handling. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of String Handling. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

String Handling MCQs | Page 3 of 6

Q21.
Which of these method of class String is used to remove leading and trailing whitespaces?
Discuss
Answer: (b).trim()
Q22.
What is the value returned by function compareTo() if the invoking string is greater than the string compared?
Discuss
Answer: (c).value greater than zero
Discuss
Answer: (a).replace() method replaces all occurrences of one character in invoking string with another character
Q24.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        { 
           String c = "  Hello World  ";
           String s = c.trim();
           System.out.println("\""+s+"\"");
        }
    }
Discuss
Answer: (c).“Hello World”
Q25.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        { 
           String s1 = "one";
           String s2 = s1 + " two";
           System.out.println(s2);
        }
    }
Discuss
Answer: (c).one two
Q26.
Which of these class is used to create an object whose character sequence is mutable?
Discuss
Answer: (b).StringBuffer()
Q27.
Which of this method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
Discuss
Answer: (b).append()
Q28.
Which of these method of class StringBuffer is used to find the length of current character sequence?
Discuss
Answer: (a).length()
Q29.
What is the string contained in s after following lines of code?
StringBuffer s new StringBuffer("Hello");
s.deleteCharAt(0);
Discuss
Answer: (b).ello
Discuss
Answer: (a).reverse() method reverses all characters
Page 3 of 6

Suggested Topics

Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!