My Report

Java String Handling Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which of these class is superclass of String and StringBuffer class?

2. Which of these method of class String is used to extract a single character from a String object?

3. What will be the output of the following Java program?

    class String_demo 
    {
        public static void main(String args[])
        {
            char chars[] = {'a', 'b', 'c'};
            String s = new String(chars);
            System.out.println(s);
        }
   }

4. What will be the output of the following Java 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);
        }
   }

5. Which of these is an incorrect statement?

6. Which of this method of class String is used to obtain a length of String object?

7. Which of these operators can be used to concatenate two or more String objects?

8. What will be the output of the following Java 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);
        }
   }

9. Which of these constructors is used to create an empty String object?


 

Start practicing “1000 MCQs on Java”, and once you are ready, you can take tests on all topics by attempting our “Java Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.