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

Explore more Topics under Java Programming

Q41.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        {
            char ch;
            ch = "hello".charAt(1);
            System.out.println(ch);
        }
   }

a.

h

b.

e

c.

l

d.

o

Discuss
Answer: (b).e
Q42.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        { 
           String s1 = "Hello";
           String s2 = new String(s1);
           String s3 = "HELLO";
           System.out.println(s1.equals(s2) + " " + s2.equals(s3));
        }
    }
Discuss
Answer: (c).true false
Q43.
In the below code, which code fragment should be inserted at line 3 so that the output will be: โ€œ123abc 123abcโ€?
 1 StringBuilder sb1 = new StringBuilder("123");
 2 String s1 = "123";
 3  // insert code here
 4 System.out.println(sb1 + " " + s1);
Discuss
Answer: (d).sb1.append(โ€œabcโ€); s1 = s1.concat(โ€œabcโ€);
Q44.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        {
             String chars[] = {"a", "b", "c", "a", "c"};
             for (int i = 0; i < chars.length; ++i)
                 for (int j = i + 1; j < chars.length; ++j)
                     if(chars[i].compareTo(chars[j]) == 0)
                         System.out.print(chars[j]); 
        }
  
Discuss
Answer: (d).ac
Q45.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        { 
           String s1 = "Hello";
           String s2 = s1.replace('l','w');
           System.out.println(s2);
        }
    }
Discuss
Answer: (d).hewwo
Q46.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        {
           String s1 = "Hello World";
           String s2 = s1.substring(0 , 4);
           System.out.println(s2);
        }
   }
Discuss
Answer: (a).Hell
Q47.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        {             String s = "Hello World";
             int i = s.indexOf('o');
             int j = s.lastIndexOf('l');
             System.out.print(i + " " + j);
 
        }
   }
Discuss
Answer: (c).4 9
Q48.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        { 
             StringBuffer c = new StringBuffer("Hello");
             StringBuffer c1 = new StringBuffer(" World");
             c.append(c1);
             System.out.println(c);
        }
    }
Discuss
Answer: (d).Hello World
Q49.
What is the output of this program?
    class output 
    {
        public static void main(String args[])
        { 
           StringBuffer s1 = new StringBuffer("Hello");
           StringBuffer s2 = s1.reverse();
           System.out.println(s2);
        }
    }
Discuss
Answer: (b).olleH
Q50.
What is the output of this program?
    class output 
    {
       class output 
       {
         public static void main(String args[])
         {
            char c[]={'A', '1', 'b' ,' ' ,'a' , '0'};
            for (int i = 0; i < 5; ++i)
            {
                   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++;
            }
        }
    }
Discuss
Answer: (c). 1 is a digit
a is a lower case Letter
Page 5 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!