Docstoc

test ans 23

Document Sample
test ans 23 Powered By Docstoc
					                                 Answers

No.            Answer                             Remark

                             There are two versions of the Math.round
                             method. One accepts an argument of type
                             float; the return type is int. The other accepts
1     e Compile-time error   an argument of type double; the return type is
                             long. A compile-time error is generated here
                             due to the attempt to assign the long return
                             value to the int variable, i2.

                             The Math.round method returns the floor of the
                             argument value plus 0.5. If the argument is of
2     d Prints: 1,2          type float, then the return type is int. If the
                             argument is of type double, then the return type
                             is long.

                             If NaN is the argument passed to Math.round,
                             then the return value is zero. If the argument
3     c Prints: 0            type is float, then the return type is int. If the
                             argument type is double, then the return type is
                             long.

                             The Math.ceil method name is not overloaded.
                             The Math.ceil method accepts an argument of
4     d Prints: 1.0,2.0      type double and returns a double. The
                             returned value is the smallest whole number that
                             is greater than or equal to the argument.

                             The Math.floor method name is not overloaded.
                             The Math.floor method accepts an argument of
5     a Prints: 0.0,1.0
                             type double and returns a double. The
                             returned value is the largest whole number that
                                      Answers

No.            Answer                                  Remark

                                  is smaller than or equal to the argument.

                                  The Math class declares four versions of the
                                  abs method; each declares one parameter. The
                                  parameter can be of type int, long, float or
                                  double. The return type is the same as the
                                  argument type. At run-time, the argument might
6     a Prints: 10.0
                                  not match the parameter type; so the argument
                                  might require an implicit conversion to an
                                  acceptable type. If the argument is of type byte,
                                  short or char, then it will be promoted to type
                                  int.

                                  At line 1, the invocation of the Math.min method
                                  produces a return value of type int. The
                                  variable b1 is of type short; so the assignment
                                  expression results in a compile-time error. The
                                  Math class declares four versions of the min
                                  method; each declares a pair of parameters of
                                  the same type. The parameter pair can be of
          Compile-time error at   type int, long, float or double. The return
7     b
          1                       type is the same as the argument types. At run-
                                  time, the arguments might not match the
                                  declared parameter types; so one argument or
                                  both might require an implicit conversion to an
                                  acceptable type. If both arguments are of type
                                  byte, short or char, then both will be
                                  promoted to type int. If only one argument is of
                                  type byte, short or char, then it will be
                                      Answers

No.             Answer                                 Remark

                                  promoted to the type of the other argument. If
                                  both arguments are of type int, long, float or
                                  double but the types differ, then a primitive
                                  widening conversion will be applied to one of the
                                  two arguments.

                                  At line 1, the invocation of the Math.min method
                                  produces a return value of type int. The
                                  variable a1 is of type byte; so the assignment
                                  expression results in a compile-time error. The
                                  Math class declares four versions of the min
                                  method; each declares a pair of parameters of
                                  the same type. The parameter pair can be of
                                  type int, long, float or double. The return
                                  type is the same as the argument types. At run-
                                  time, the arguments might not match the
          Compile-time error at
8     b                           declared parameter types; so one argument or
          1
                                  both might require an implicit conversion to an
                                  acceptable type. If both arguments are of type
                                  byte, short or char, then both will be
                                  promoted to type int. If only one argument is of
                                  type byte, short or char, then it will be
                                  promoted to the type of the other argument. If
                                  both arguments are of type int, long, float or
                                  double but the types differ, then a primitive
                                  widening conversion will be applied to one of the
                                  two arguments.

9     c Prints: int,int,int       The Math class declares four versions of the
                                Answers

No.          Answer                              Remark

                            min method; each declares a pair of parameters
                            of the same type. The parameter pair can be of
                            type int, long, float or double. The return
                            type is the same as the argument types. At run-
                            time, the arguments might not match the
                            declared parameter types; so one argument or
                            both might require an implicit conversion to an
                            acceptable type. If both arguments are of type
                            byte, short or char, then both will be
                            promoted to type int. If only one argument is of
                            type byte, short or char, then it will be
                            promoted to the type of the other argument. If
                            both arguments are of type int, long, float or
                            double but the types differ, then a primitive
                            widening conversion will be applied to one of the
                            two arguments.

                            The Math class declares four versions of the
                            min method; each declares a pair of parameters
                            of the same type. The parameter pair can be of
                            type int, long, float or double. The return
                            type is the same as the argument types. At run-
                            time, the arguments might not match the
10 d Prints: int,int,long
                            declared parameter types; so one argument or
                            both might require an implicit conversion to an
                            acceptable type. If both arguments are of type
                            byte, short or char, then both will be
                            promoted to type int. If only one argument is of
                            type byte, short or char, then it will be
                               Answers

No.          Answer                             Remark

                           promoted to the type of the other argument. If
                           both arguments are of type int, long, float or
                           double but the types differ, then a primitive
                           widening conversion will be applied to one of the
                           two arguments.

                           The Math class declares four versions of the
                           min method; each declares a pair of parameters
                           of the same type. The parameter pair can be of
                           type int, long, float or double. The return
                           type is the same as the argument types. At run-
                           time, the arguments might not match the
                           declared parameter types; so one argument or
                           both might require an implicit conversion to an
       Prints:
11 c                       acceptable type. If both arguments are of type
       long,float,double
                           byte, short or char, then both will be
                           promoted to type int. If only one argument is of
                           type byte, short or char, then it will be
                           promoted to the type of the other argument. If
                           both arguments are of type int, long, float or
                           double but the types differ, then a primitive
                           widening conversion will be applied to one of the
                           two arguments.

                           The Math.random method returns a value of type
12 d Prints: double        double. The range of values is greater than or
                           equal to zero and less than one.

                           The Math.random method does not accept a
13 e Compile-time error
                           seed value. If your application requires a seed,
                                      Answers

No.             Answer                                Remark

                                 then use java.util.Random.

          Prints:                The Math.sin, Math.cos and Math.tan methods
14 d
          double,double,double   return a value of type double.

      a
      g                          The Math.random method returns a value that is
15        b1 b7 b8 b9
      h                          equal to or greater than zero and less than 1.0.
      i

                                 All methods of the java.lang.Math class are
16 l None of the above
                                 static.

      a
17 d abs max min
      e

                                 The round method does not return either of the
                                 two floating point primitive types, float or
                                 double. The ceil, sin and sqrt methods
18 f Prints: DDDLDD              return only a value of type double. The abs and
                                 max methods are able to return an int, long,
                                 float or double depending on the argument
                                 type.

                                 The floor and ceil methods are not
                                 overloaded. There is only one version of each
19 e Prints: DDDD
                                 method. The parameter type is double, and the
                                 return type is double.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:0
posted:10/20/2012
language:English
pages:6