Step-by-Step Method Call

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

What is the location of pointB after the following:

pointB.move( 24-12, 30*3 + 5 );

Answer:

pointB will now be located at x = 12, y = 95.

Step-by-Step Method Call

You probably did the right thing to get the answer, but let us go through it again, just to be sure:

pointB.move( 24-12, 30*3 + 5 );

is equivalent to:

pointB.move( 12, 30*3 + 5 );

is equivalent to:

pointB.move( 12, 90 + 5 );

is equivalent to:

pointB.move( 12, 95 );

At this point, the move() method starts running with the two int values it requires.

The expressions in the parameter list are evaluated before the method starts running. The resulting values should be the data type expected by the method, or a data type that can be converted to that type.

QUESTION 4:

What do you suspect will happen with the following method call?

pointB.move( 14.305, 34.9 );