Page 384 - Computer science 868 Class 12
P. 384

System.out.println(str);
                    // Output: “123”
                  6.  String str=" India is one of the oldest civilizations in the world";
                    What will be the result of each of the following?
                     a.  str.substring(4,12);
                     b.  str.charAt(2)+str.charAt(str.length()-5);
                     c.  str.toUpperCase();
                     d.  str.concat(" great india");
                     e.  str.charAt(4) + str.compareTo("India was");
                Ans.  a.  ia is on
                     b.  229
                     c.  INDIA IS ONE OF THE OLDEST CIVILIZATIONS IN THE WORLD
                     d.  India is one of the oldest civilizations in the world great india
                     e.  64
                  7.  What will be the result of the following?
                    String x = "Computer", y = "Applications";
                    System.out.println(x.equals(y));
                Ans.  false
                  8.  What will be the result of the following?
                    String str = "Information Technology";
                    int p;
                    p = str.indexOf('n');
                    System.out.println(p);
                Ans.  1
                  9.  What will be the result of the following?
                     "Define".compareTo("define");
                Ans.  This function will return -32
                 10.  String x = "Target";
                    String y = "2022";
                    System.out.println(x + y);
                Ans.  Target2022
                 11.  What will be the result of the following?
                     boolean p;

                    p = ("BLUEJ".length() > "bluej".length()) ? true: false;
                Ans.  false
                 12.  What will be the result of the following?
                    public static void main(String []args)
                    {
                      String str=”INdiAn ArMy”, newstr=””;
                      String st=””;
                      int i=0;
                      while(i<str.length())
                      {
                          if(Character.isLowerCase(str.charAt(i)))
                              newstr+=Character.toUpperCase(str.charAt(i));
                          else
                          if(Character.isUpperCase(str.charAt(i)))


                382382  Touchpad Computer Science-XII
   379   380   381   382   383   384   385   386   387   388   389