|
(Thought question:) Do you think that the following will work:
A good answer might be:
Yes---the type cast | |
Can a Method Change a Primitive Type?Examine the following code fragment:
When a primitive variable is used as a parameter for any method at all, the method will not change the value in the variable. So the above fragment will print: This will be true, regardless of what exact class someClass is and what method someMethod is.x is: 32 When an object is used as a parameter for some methods of some classes, the object's data will change. You have to read the documentation of the class to know when this is the case. Most methods do not change their parameters, since doing so can cause confusion and errors. For the most part, parameters are used to pass data into a method to tell it what to do. | |
QUESTION 11:Examine the following code fragment: The parameters x and y contained short values which had to be converted into int values for the method. Were the contents of x and y altered by this conversion? Click Here after you have answered the questionPoint B = new Point(); short x = 16, y = 12; B.move( x, y ); |