Page 440 - CA_Blue( J )_Class10
P. 440

String sub = str.substring(7);
                    System.out.println(sub);
                    a.  Hello                                        b  Hello, World!
                    c.  World!                                       d  ,World!
                  5.  What does the substring(int beginIndex, int endIndex) method do?
                    a.  Extracts a substring starting from beginIndex to endIndex
                    b.  Extracts a substring starting from beginIndex to endIndex 1
                    c.  Extracts a substring from the beginning of the string to endIndex 1
                    d.  Extracts a substring from beginIndex + 1 to endIndex
                Ans.  1. b   2. c   3. c   4. c   5. b


                   Unsolved Questions



              A.  Tick ( ) the correct answer.
                  1.  Which of the following operators is used to concatenate two or more strings?
                    a.  *                                           b.  ^
                    c.  +                                           d.  #
                  2.  Consider the following code:
                    String s = "ORANGE";
                    String s1 = "education";
                    System.out.println(s + s1.toUpperCase());
                    Which of the following is the output of the preceding code?
                    a.  ORANGEEDUCATION                             b.  ORANGEeducation
                    c.  ORANGE EDUCATION                            d.  None of these
                  3.  Which of the following methods is used to compare two String objects for their equality?
                    a.  equals()                                    b.  Equals()
                    c.  isequal()                                   d.  All of these
                  4.  Consider the following code:
                    String Str1 = "I am a good student";
                    String Str2 = "am";
                    String Str3 = "was";
                    System.out.println(Str1.replace(Str2, Str3));
                     Which of the following is the output of the preceding code?
                    a.  I was a good student                        b.  I am a good student
                    c.  I was good student                          d.  Nothing will print
                  5.  Which of the following is the correct way to declare a String in Java?
                    a.  String str=new String("INDIA");             b.  String str = "INDIA ";
                    c.  Both a and b                                d.  None of these
                  6.  What will be the output of the following code?
                    String s = "Computer";
                    s = s.concat(" Applications");
                    System.out.println(s);
                    a.  Applications                                b.  ComputerApplications
                    c.  Computer Applications                       d.  Compilation error
                  7.  Which of the following methods is used to convert a string to uppercase in Java?
                    a.  ToUpper()                                   b.  toUppercase()
                    c.  toUpperCase()                               d.  convertToUpper()







                438438  Touchpad Computer Applications-X
   435   436   437   438   439   440   441   442   443   444   445