December 21, 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
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
Question 3
What string is now returned when the following expression is evaluated.
What is the textual representation of the string?
(billsSpareChangeAccount holder) printString
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 |
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' |
Back to « Textual representation of objects
⇑ Up to top of page