March 19, 2024

Smalltalk Exercises - Textual Representation and Print-strings

 

Clicking on the A graphic will produce the answer to each question.

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

 

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

 

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

 

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

 

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

 

Back to « Textual representation of objects

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Up to top of page