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 4 of 6

Explore more Topics under Java Programming

Q31.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        {
            String a = "hello i love java";
            System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v'));
        }
    }
Discuss
Answer: (d).1 14 8 15
Q32.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        { 
             StringBuffer c = new StringBuffer("Hello");
             c.delete(0,2);
             System.out.println(c);
        }
    }
Discuss
Answer: (d).llo
Q33.
Which of these methods of class StringBuffer is used to extract a substring from a String object?
Discuss
Answer: (a).substring()
Q34.
What will s2 contain after following lines of code?
StringBuffer s1 = "one";
StringBuffer s2 = s1.append("two")
Discuss
Answer: (c).onetwo
Q35.
Which of this method of class StringBuffer is used to reverse sequence of characters?
Discuss
Answer: (a).reverse()
Q36.
Which of this method of class StringBuffer is used to get the length of the sequence of characters?
Discuss
Answer: (a).length()
Q37.
Which of the following are incorrect form of StringBuffer class constructor?
Discuss
Answer: (d).StringBuffer(int size , String str)
Q38.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        { 
             StringBuffer c = new StringBuffer("Hello");
             System.out.println(c.length());
        }
    }

a.

4

b.

5

c.

6

d.

7

Discuss
Answer: (b).5
Q39.
What is the output of this program?
  class output 
  {  
      public static void main(String args[]) 
      {  
          StringBuffer sb=new StringBuffer("Hello");  
          sb.replace(1,3,"Java");  
          System.out.println(sb);
      }  
  }
Discuss
Answer: (c).Hjavalo
Q40.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        {
            char c[]={'a', '1', 'b' ,' ' ,'A' , '0'};
            for (int i = 0; i < 5; ++i)
            {
                   if(Character.isDigit(c[i]))
                       System.out.println(c[i]+" is a digit");
                   if(Character.isWhitespace(c[i]))
                       System.out.println(c[i]+" is a Whitespace character");
                   if(Character.isUpperCase(c[i]))
                       System.out.println(c[i]+" is an Upper case Letter");
                   if(Character.isLowerCase(c[i]))
                       System.out.println(c[i]+" is a lower case Letter");
               i=i+3;
            }
        }
    }
Discuss
Answer: (c).a is a lower case Letter
A is an upper case Letter
Page 4 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!