CS 535 Object-Oriented Programming
Fall Semester, 2003
Past Exam Questions
Course Web Site
© 2003, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 23-Oct-03
are some questions that have appeared on past CS 535 exams. They may or may not
be related to questions on future exams. I will not be providing answers to the
Describe the Smalltalk naming convention for:
What is the difference between True and true in Smalltalk?
Explain the difference between self and super. Give an example as part of your
explanation. If you define classes for you example give the parent class, class
name, instance variables and methods. The exact template for creating a class
is not needed.
What is an overridden method. Given an example.
What are the Smalltalk rules for overridding instance variables?
Let aCollection contain a collection of numbers. Use inject:into: to find the
smallest element in aCollection.
Explain the difference between OrderedCollection and a Bag.
What is polymorphism? Give an example.
Write a Smalltalk program to print the odd numbers between 21 and 5342 on the
What is the difference between == (double equals) and = (single equals) in
What is the difference between select: and collect:?
What is a Template method? Give an example of the use of Template Method in the
Smalltalk class library.
12. Given the methods below what is printed on the Transcript by executing the
expression: ‘Exam new a’
show: 'Start a’;
show: 'End a’;
show: 'Start b’;
self c: [^5].
show: 'End b’;
show: 'Start c’;
show: 'End c’;
13. Given the classes and methods below what is the result of executing each of the
following expressions individually with “print it”?
C new foo
C new bar
A new foo
14. Parenthesis the following expressions to indicate the order that messages will
be sent in the expression. For keyword messages list separately the full
keyword message name.
y asSet asBag printString.
1 * 2 + 3 - 4 / 5 * 6 - 1.
circle origin = 1 @ 2.
sam long age: x x + x x.
cat printString copyFrom: dog size to: mouse at: 2.
Circle new origin: 3 @ 2; radius: cat at: 2; color: dog displayColor.
15. Write a class method for a class named Foo that has one argument that is an
ordered collection of strings. Return the list sorted by the second character.
16. Write SUnit test method(s) for the sort method in the above problem.
Copyright ©, All rights reserved.
2003 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.
visitors since 23-Oct-03