This site will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device.

John McSweeney - picture detail

John McSweeney

May 12, 2008, 1:53 pm

M206 Computing: An Object-oriented Approach

Smalltalk Exercises - Precedence

 

Clicking on the A graphic will open up a window displaying the answer to each question (switch off pop-up blocker if you have one enabled).

Question 1
What object is returned after the following expression series is evaluated in a Workspace?
What is the textual representation of the message answer?

10 - (17 - 10)plus: 10

Link to answer for Q1. Left click and a new window will open

 

Question 2
What answer is returned after the following expression series is evaluated in a Workspace?
You can assume that aFrog and aToad are initialised instances.
What then is the position of aToad?
What is the textual representation of the message answer?

aToad position: aFrog position + 3 * 2 -  aToad position

Link to answer for Q2. Left click and a new window will open

 

Question 3
What answer is returned after the following expression series is evaluated in a Workspace? What then is the balance of myAccount?
You can assume that myAccount references an instance of Account and has its instance variable balance set to 500.

myAccount balance: (myAccount balance) - 100 / 2 * 5

Link to answer for Q3. Left click and a new window will open

 

Back to « Precedence