|
What will be the output of the program? A good answer might be:
New location:java.awt.Point[x=14,y=22] | |
Automatic Conversion of Parameter TypeIn the previous example, converting from floating-point to int results in a lose of information, so the programmer must explicitly ask for conversion with a type cast. When a conversion from one type to another type can be done without loss of information, the compiler will do it automatically. For example, the description of the move() method says that it requires two int parameters:
An int value is held in 32 bits.
A short value that is held in 16 bits can be converted to 32 bits
without loss of information.
Why? The information encoded in 16 bits can also be encoded in 32 bits. So the following program will compile and run correctly:
| |
QUESTION 6:What will this program write to the monitor? Click Here after you have answered the question |