Page 444 - CA_Blue( J )_Class10
P. 444

appropriate option given below:
                    a.  Both A and R are true, and R is the correct explanation of A.
                    b.  Both A and R are true, but R is not the correct explanation of A.
                    c.  A is true, but R is false.
                    d.  A is false, but R is true.
                  1.  Assertion (A): The charAt() method is used to extract a character at a specific index from a string.
                     Reason (R): The charAt() method returns the ASCII value of the character at the specified index.
                  2.  Assertion (A): The trim() method in Java removes whitespace from both ends of a string.
                     Reason (R): The trim() method modifies the original string to remove leading and trailing whitespace characters.
                  3.  Assertion (A): The startsWith() method can be used to verify if a string starts with a specific sequence of characters.
                     Reason (R): The startsWith() method returns true if the beginning of the string matches the specified prefix.

                                                                                               21 st
              E.  Case-based questions.                                                      Century   #Experiential Learning
                                                                                               Skills
                    In Java, a String array is a data structure that holds a fixed number of String values. Arrays are used to store multiple values in a
                    single variable, instead of declaring separate variables for each value. Here's an overview of String arrays in Java:
                     You can declare a String array in the following ways:
                     String[] array1;  OR  String array2[];
                     You can initialize a String array
                  a.  Static Initialization:
                    String[] array = {"Hello", "World", "Java"};
                  b.  Dynamic Initialization:
                    String[] array = new String[3]; // Array with 3 elements, all initialized to null
                    array[0] = "Hello";
                    array[1] = "World";
                    array[2] = "Java";
                  1.  What is a String array in Java?
                    a.  A data structure that holds a fixed number of integer values.
                    b.  A data structure that holds a fixed number of boolean values.
                    c.  A data structure that holds a fixed number of String values.
                    d.  A data structure that holds a variable number of String values.
                  2.  How can you declare a String array in Java?
                    a.  String array1[];                            b.  String[] array2;
                    c.  Both a and b                                d.  None of these

                  3.  Which of the following is an example of static initialization of a String array?
                    a.  String[] array = {"Hello", "World", "Java"};
                    b.  String[] array = new String[3];
                    c.  String[] array = new String[];
                    d.  String[] array = new String[3]{"Hello", "World", "Java"};
                  4.  What are the different ways to initialize the String Array?
                    a.  Static initialization                       b.  Dynamic initialization
                    c.  Both a and b                                d.  None of these

                  5.  What is a size of the array[]:
                    a.  0                                           b.  1
                    c.  14                                          d.  3








                442442  Touchpad Computer Applications-X
   439   440   441   442   443   444   445   446   447   448   449