December 21, 2024

Smalltalk Exercises - Booleans

 

Smalltalk Exercises - Booleans

 

Clicking on the A graphic will go to the answer.

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

(a)
('truth' = 'truth' ) & ('lies' = 'lies')
(b)
('truth' = 'truth' )not & ('lies' = 'lies')not
(c)
('truth' = 'truth' )not | ('lies' == 'lies')not

Link to answer for Q1

 

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.

(a)
aToad position - 10 == aFrog position | (aToad colour = aFrog colour)
(b)
aToad position - 10 == aFrog position | aToad colour = aFrog colour
(c)
(aToad position - 10 == aFrog position) not  & (aToad colour = aFrog colour) not

Link to answer for Q2

 

Question 3
What answer is returned after the following expression series is evaluated in a Workspace?

(a)
var1 := 20.
var2 := var1 * 2.
(var2 - var1 >= var1) & (var2 > (var1 * 2))
(b)
x := 99.
y := 100.
((x + y) > (y * 2)) not & ((y - x) >= (x/x))
(c)
('true' == 'true') ~= true

Link to answer for Q3

 

Back to « Booleans

 

Back to « Precedence

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Up to top of page