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:31 pm

M206 Computing: An Object-oriented Approach

Smalltalk Exercises - Booleans

 

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
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. 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.

(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. Left click and a new window will open

 

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. Left click and a new window will open

 

Back to « Booleans