Page 343 - CA_Blue( J )_Class10
P. 343

c.  Converts wrapper classes to primitive data types   d.  Converts primitive data types to wrapper classes
                    iii.  Which method can convert different types of values, including primitive data types, to their string representations?
                       a.  toString()                                  b.  valueOf()
                       c.  getString()                                 d.  parseString()
                    2.  Answer from the program snippet?
                       int value = 123456789L;
                       String str = String.valueOf(value); // Convert long to String
                       double parsedValue = Double.parseDouble(str); // Parse String to double
                     i.  What is the purpose of the String.valueOf() method in the given code?
                       a.  Converts a string to a long value           b.  Converts a long value to a string
                       c.  Parses a string to a double value           d.  Parses a double value to a string
                    ii.  What does the Double.parseDouble() method do in the given code?
                       a.  Converts a string to a double value         b.  Converts a double value to a string
                       c.  Converts a long value to a double value     d.  Converts a double value to a long value
                    iii.  What is the error in the program?
                       a.  double parsedValue = Double.parseDouble(str);   b.  String str = String.valueOf(value);
                       c.  int value = 123456789L;                     d.  None of the above

                                             Previous Years' Questions


                    1.  Write a difference between the functions isUpperCase() and toUpperCase().                   [2018]
                   Ans.
                                           isUpperCase()                                   toUpperCase()
                       It checks whether the String/character is in capital letter or not.  It converts the String/character to capital letters.
                       It returns boolean value.                           It returns String value.
                    2.  Name the package that contains wrapper classes.                                             [2018]
                   Ans.  The java.lang package contains the wrapper classes.
                    3.  State the data type and value of res after the following is executed:                       [2017]
                       char ch ='t';
                       char res = Character.toUpperCase(ch);
                   Ans.  Data type of res is char and value is'T'.
                    4.  Give the output of the following code:                                                      [2017]
                       String A = "26", B = "100";
                       String D = A + B + "200";
                       int x = Integer.parseInt(A);
                       int y = Integer.parseInt(B);
                       int d = x + y;
                             System.out.println("Result 1 = " + D);
                       System.out.println("Result 2 = " + d);
                   Ans.  Result 1 = 26100200
                       Result 2 = 126
                    5.  Name any two library packages.                                                              [2016]
                   Ans.  The java.util and java.io are two library packages.
                    6.  Write one difference between primitive data types and composite data types.                 [2016]
                   Ans.
                                 Primitive Data Type                              Composite Data type
                       Primitive data types are in-built data types.  Composite data types are those data types that are defined by the user using
                                                             the primitive data types.
                    7.  Write the return type of the following library function:                                    [2016]
                       isLetterOrDigit(char)
                   Ans.  boolean





                                                                                                                       341
                                                                                                        Library Classes    341
   338   339   340   341   342   343   344   345   346   347   348