The pages of this web site are not formatted to conserve paper, but my new book (ISBN: 0-9745862-0-X) is formatted to save paper, save your printer toner, and save money. If you prefer to work my exams from printed pages, then you can save a tree, save your printer toner, and save money if you buy my new book instead of attempting to print the pages of my web site.
Today, you can find my book on the retail web site of the company that prints it and distributes it.
| No. | Answer | Remark | |
|---|---|---|---|
| 1 | e | Compile-time error |
There are two versions of the
|
| 2 | d | Prints: 1,2 |
The
|
| 3 | c | Prints: 0 |
If
NaN
is the argument passed to
|
| 4 | d | Prints: 1.0,2.0 |
The
|
| 5 | a | Prints: 0.0,1.0 |
The
|
| 6 | a | Prints: 10.0 | 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 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. |
| 7 | b | Compile-time error at 1 |
At line 1, the invocation of the
|
| 8 | b | Compile-time error at 1 |
At line 1, the invocation of the
|
| 9 | c | Prints: int,int,int | 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 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. |
| 10 | d | Prints: int,int,long | 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 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. |
| 11 | c | Prints: long,float,double | 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 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. |
| 12 | d | Prints: double |
The
|
| 13 | e | Compile-time error |
The
|
| 14 | d | Prints: double,double,double |
The
|
| 15 | a g h i | b1 b7 b8 b9 |
The
|
| 16 | l | None of the above |
All methods of the
|
| 17 | a d e | abs max min | |
| 18 | f | Prints: DDDLDD | The round method does not return either of the two floating point primitive types, float or double. The ceil, sin and sqrt methods 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. |
| 19 | e | Prints: DDDD | The floor and ceil methods are not overloaded. There is only one version of each method. The parameter type is double, and the return type is double. |