the string class Flashcards

1
Q

This section of our 1000+ Java MCQs focuses on String class of Java Programming Language.

  1. String in Java is a?
    a) class
    b) object
    c) variable
    d) character array
A

a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. Which of these method of String class is used to obtain character at specified index?
    a) char()
    b) Charat()
    c) charat()
    d) charAt()
A

d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. Which of these keywords is used to refer to member of base class from a subclass?
    a) upper
    b) super
    c) this
    d) none of the mentioned
A

b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. Which of the following statements are incorrect?
    a) String is a class
    b) Strings in java are mutable
    c) Every string is an object of class String
    d) Java defines a peer class of String, called StringBuffer, which allows string to be altered
A

b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
class string_demo 
    {
        public static void main(String args[])
        {
            String obj = "I" + "like" + "Java";   
            System.out.println(obj);     
        }
   }
a) I
b) like
c) Java
d) IlikeJava
A

d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

class string_class
{
public static void main(String args[])
{
String obj = “I LIKE JAVA”;
System.out.println(obj.charAt(3));
}
}
a) I
b) L
c) K

A

a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
class string_class 
    {
        public static void main(String args[])
        {
            String obj = "I LIKE JAVA";   
            System.out.println(obj.length());
        }
    }
a) 9
b) 10
c) 11
d) 12
A

c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
class string_class 
    {
        public static void main(String args[])
        {
            String obj = "hello";
            String obj1 = "world";   
            String obj2 = obj;
            obj2 = " world";
            System.out.println(obj + " " + obj2);
        }
    }
a) hello hello
b) world world
c) hello world
d) world hello
A

c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
class string_class 
    {
        public static void main(String args[])
        {
            String obj = "hello";
            String obj1 = "world";   
            String obj2 = "hello";
            System.out.println(obj.equals(obj1) + " " + obj.equals(obj2));
        }
    }
a) false false
b) true true
c) true false
d) false true
A

d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
1. String class belongs to \_\_\_\_\_\_\_\_\_\_ package
A java.awt

B java.lang

C java.applet

D java.string

A

b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
. Which of the following methods of the “StringBuffer” class is used to find the length of a String?
A length()

B Length()

C Capacity()

D capacity()

A

a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly