Which of these method of class String is used to extract all the characters from a String object?

b) Substring()

c) SubString()

d) None of the mentioned

2. What will s2 contain after following lines of Java code?

 StringBuffer s1 = "one";

StringBuffer s2 = s1.append("two")

a) one

b) two

c) onetwo

d) twoone

3. Which of this method of class StringBuffer is used to reverse sequence of characters?

a) reverse()

b) reverseall()

c) Reverse()

d) reverseAll()

4. Which of this method of class StringBuffer is used to get the length of the sequence of characters?

a) length()

b) capacity()

c) Length()

d) Capacity()

5. Which of the following are incorrect form of StringBuffer class constructor?

a) StringBuffer()

b) StringBuffer(int size)

c) StringBuffer(String str)

d) StringBuffer(int size , String str)

6. What will be the output of the following Java code?

  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

7. What will be the output of the following Java code?

 class output 

 {  

   public static void main(String args[]) 

   {  

     StringBuffer sb=new StringBuffer("Hello");  

     sb.replace(1,3,"Java");  

     System.out.println(sb);

   }  

 }

a) Hello java

b) Hellojava

c) HJavalo

d) Hjava

8. What will be the output of the following Java code?

  class output 

  {

    public static void main(String args[])

    { 

      StringBuffer s1 = new StringBuffer("Hello");

      s1.setCharAt(1,'x');

      System.out.println(s1);

    }

  }

a) xello

b) xxxxx

c) Hxllo

d) Hexlo

9. What will be the output of the following Java code?

  class output 

  {

    public static void main(String args[])

    {

      StringBuffer s1 = new StringBuffer("Hello World");

      s1.insert(6 , "Good ");

      System.out.println(s1);

    }

  }

a) HelloGoodWorld

b) HellGoodoWorld

c) HellGood oWorld

d) Hello Good World

10. What will be the output of the following Java code?

  class output 

  {

    public static void main(String args[])

    { 

      StringBuffer s1 = new StringBuffer("Hello");

      s1.insert(1,"Java");

      System.out.println(s1);

    }

  }

a) hello

b) java

c) Hello Java

d) HJavaello

Answer & Explanation

Which of these method of class String is used to extract all the characters from a String object?
Solved by verified expert

at, ul, consectetur

iciturur laoree

Fusce, consectetu

lestiefacilisis.

iciturac, dictum vitae odio. Donec aliquet.

risusce d

ec facipsum dolo

, dictu, consec

usce duicitur laoreet. Nam

inia pulec facilisis

gue

Unlock full access to Course Hero

Explore over 16 million step-by-step answers from our library

Subscribe to view answer

Step-by-step explanation

leamet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque d

gue

iacongue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dol

gue

acifacilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie co

gue

, cur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac m

gue

dicdictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam

gue

fmolestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsu

gue

remur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec alique

gue

tctum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor

gue

ces a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem

gue

ce dat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum

Which method is used to extract a character from String?

You can extract a substring from a string using the slice() method. You pass it: the index at which to start extracting.

Which of these method of class String is used to extract all the character from a String object?

charAt() is the method of class String is used to extract a single character from a String Object. Hence, option(c) is the correct answer. Java uses the syntax of camel-case for naming class, interface, method, and variable. charAt() is a string method that returns the character present at the given index in a string.

Which of these methods of class String is used to extract all the characters from a String object * A charAt () b remove () C charAt () d replace ()?

Explanation: Replace() replaces all instances of a character with a new character while Remove extracts characters from the string.

Which of this method of class String is used to extract a substring from a String object Mcq?

1. Which of these methods of class StringBuffer is used to extract a substring from a String object? Explanation: None.