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

March 12, 2010, 5:32 pm

M206 Computing: An Object-oriented Approach

Smalltalk Exercises - Textual Representation and Print-strings

 

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?

fred := Frog new.
fred colour: Blue.
(fred printString) dropVowels

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

 

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

billsSpareChangeAccount := Account new.
billsSpareChangeAccount holder: 'William Gates III';
                        balance: 536870912;
                        overLimit: 1.
(billsSpareChangeAccount printString) dropVowels

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

 

Question 3
What string is now returned when the following expression is evaluated.
What is the textual representation of the string?

(billsSpareChangeAccount holder) printString

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

 

Question 4
Complete the table below after the Smalltalk expressions have been evaluated in a Workspace.

Smalltalk expression Class of answer Textual representation of answer
34    
'34'    
34 printString    

'34' printString

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

 

Question 5
Complete the table below after the evaluation of the Smalltalk expressions.
You can assume that kermit references an initialised instance of Frog.

Smalltalk expression Class of answer Textual representation of answer
kermit    
kermit position printString    
kermit colour printString, ' Onions'    
Link to answer for Q5. Left click and a new window will open

 

Back to « Textual representation of objects