Page 339 - CA_Blue( J )_Class10
P. 339

5.  To include the packages in the program, the keyword ………………… is used.

                  Answers
                  1. isLetterOrDigit()     2. parseDouble(), valueOf()       3. UnBoxing    4. isWhitespace()     5. import



                 C.  Answer the following questions:
                    1.  Which package contains Wrapper classes?
                   Ans.  The java.lang package contains wrapper classes.
                    2.  Write down the output and the return type of the following code:
                       double d=34.6;
                       sd = Double.toString(d);
                   Ans.  Output: 34.6                                  Return type: String
                    3.  Write down the return type of the toLowerCase() method.
                   Ans.  String
                    4.  Write the difference between toLowerCase(char ch) and isLowerCase(char ch) methods.
                   Ans.
                                    toLowerCase(char ch)                             isLowerCase(char ch)
                       Converts the character ch to lowercase.     Checks whether the character ch is in lowercase or not.
                       Returns char data type.                     Returns boolean data type.
                       Example: Character.toLowerCase('B');        Example: Character.isLowerCase('B')
                       Returns: b                                  Returns: false

                    5.  What will be the output of the following:
                         String s1= "45", s2= "200", s3 = s1+s2;
                       int in= Integer.parseInt(s1+s2);
                        System.out.println("Result after Wrapper class is used: " + in);
                        System.out.println("Result without using Wrapper class: " s1+s2);
                   Ans.  Result after Wrapper class is used: 45200
                       Result without using Wrapper class: 45200
                    6.  What will be the output of the following:
                         String s1= "45", s2= "200", s3 = s1+s2;
                       int in= Integer.parseInt(s1+s2)+30;
                       System.out.println("Result: " + in);
                       System.out.println((s1+s2)+30);
                   Ans.  Result:  45230
                             4520030
                    7.  What are the return data types of the following methods?
                       a.  isLowerCase(char)                           b.  toUpperCase(char)
                       c.  Integer.parseInt(String)                    d.  Double.valueOf(String)
                       e.  Float.toString(float)
                   Ans.  a.  boolean                                   b.  char
                       c.  int                                         d.  double
                       e.  String
                    8.  Write down the methods used to do the following:
                       a.  Checks whether the character is a digit or not.   b.  Converts the letter to upper case.
                       c.  Converts the String to float.               d.  Checks whether it is a space or not.
                       e.  Converts the integer to String.
                   Ans.  a.  Character.isDigit(char)                   b.  Character.toUpperCase(char)
                       c.  Float.parseFloat(String)                    d.  Character.isWhitespace(char)
                       e.  Integer.toString(char)





                                                                                                                       337
                                                                                                        Library Classes    337
   334   335   336   337   338   339   340   341   342   343   344