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

Q1.
Which of these class is superclass of String and StringBuffer class?
Discuss
Answer: (b).java.lang
Q2.
Which of this method of class String is used to obtain a length of String object?
Discuss
Answer: (d).length()
Q3.
Which of these method of class String is used to extract a single character from a String object?
Discuss
Answer: (c).charAt()
Discuss
Answer: (c).StringBuffer class is used to store string in a buffer for later use
Q5.
What is the output of this program?
    class String_demo 
    {
        public static void main(String args[])
        {
            char chars[] = {'a', 'b', 'c'};
            String s = new String(chars);
            System.out.println(s);
        }
   }
Discuss
Answer: (d).abc
Q6.
What is the output of this program?
    class String_demo 
    {
        public static void main(String args[])
        {
            int ascii[] = { 65, 66, 67, 68};
            String s = new String(ascii, 1, 3);
            System.out.println(s);
        }
   }
Discuss
Answer: (b).BCD
Q7.
What is the output of this program?
    class String_demo 
    {
        public static void main(String args[])
        {
            char chars[] = {'a', 'b', 'c'};
            String s = new String(chars);
            String s1 = "abcd";
            int len1 = s1.length();
            int len2 = s.length();
            System.out.println(len1 + " " + len2);
        }
   }
Discuss
Answer: (d).4 3
Q8.
Which of these method of class String is used to extract more than one character at a time a String object?
Discuss
Answer: (d).getChars()
Q9.
In below code, what can directly access and change the value of the variable name?
 package test;
 class Target 
 {
  public String name = "hello";
 }
Discuss
Answer: (c).any class in the test package
Q10.
What will be output of the following code?
public class Boxer1 
{
    Integer i;
    int x;
   public Boxer1(int y) 
   {
        x = i+y;
        System.out.println(x);
   }
   public static void main(String[] args) 
   {
       new Boxer1 (new Integer(4));
   }
}
Discuss
Answer: (d).An IllegalStateException occurs at runtime
Page 1 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!