Escolar Documentos
Profissional Documentos
Cultura Documentos
First Semester
Date: 15 / 1 / 2007
Section Number:
General Instructions
The exam consists of three parts. The first part consists two sections. Section A
consists of 10 True/False questions. Each question is worth 1 mark. Section B
consists of 25 multiple choice questions. Each question is worth 2 marks. You should
answer all questions of part 1. You must answer this question in the answer sheet
given in page 8.
The second part consists of 8 short questions. Each question is worth 6 marks. You
should answer all questions of part 2.
The third part consists of 3 long questions. Each question is worth 21 marks. You
should select two of the three questions. Read the three questions first before
deciding which ones to answer.
2
FORM A
Part 1
A) Instructions: Answer the following 10 True/False questions and fill your answers in
the table of the Answers Sheet given at the end of Part 1. [10 marks]
1. When a method is defined for a subclass, it immediately becomes available to all instances
of that class as well as all instances of its superclass.
2. The messages left and right in the Frog and Toad classes are examples of
polymorphic messages.
4. A user interface designer should ignore the age and the cultural background of likely users.
7- The protocol consists only from the messages that change the object state.
8. Character objects are specified in the Smalltalk system by prefixing the character with the $
(dollar sign) symbol.
10. As with all other concrete classes, instances of Fraction class can be created using the
new class message.
B) Instructions: Answer the following 25 multiple choice questions and fill your answers
in the table of the Answers Sheet given at the end of Part 1. [50 Marks]
1- A piece of information or property needed by the object to define its state, is called:
a. Attribute
b. Class
b. Behavior
c. Object
2. "The provision of a barrier protecting the information owned by an object". This refers to
which object oriented concept?
a. Polymorphism
b. Inheritance
c. Protection
d. Encapsulation
3
3- The answer message for the following expression series:
5 + 4.
6/2
is:
a. 3
9
b. 9
3
c. 3
d. 9
height
"Answer the height of the receiver."
^height
4
7.What is the expected answer of the following method which is added to the Account class
protocol?
aMethod
"Comment omitted"
self balance:500;overLimit:3000;holder:'Rami'.
self holder:(self holder, ' Ahmad')
9. In the message expression turtle crawl:Left by:3 , the message selector is:
a. crawl:Left by:3
b. crawl:by:
c. crawl:,by:
d. Left,3
11. Which part of the system remains unchanged irrespective of whatever user interface we
use?
a. Graphical Interface
b. Textual Interface
c. Domain model
d. All the above
5
12. What type of error is present in the following fragment of code:
checkPosition
"If the current position of the receiver is equal to its maxPosition, answer true, else
answer false."
(self position = self maxPosition)
ifTrue: [^false]
ifFalse: [^true]
a. Syntax
b. Semantics
c. Logical
d. There is no error in the code
13. Which of the following methods is not in the protocol of class Set?
a. size
b. remove:
c. add:
d. at:put:
14. If a = #red, b = #red, c = ‘red’, d = ‘red’, which of the following statements is false?
a. a = b
b. a = = b
c. c = d
d. c = = d
17. What is the drawback of compiling the source code into a machine code directly?
a. The compiled code is harder to debug.
b. The compiled code cannot be translated back again.
c. The compiled code is not portable to other machine architectures.
d. The virtual machine can't read the compiled code.
6
18. The scope of a class variable is:
a. The class and instance methods of the class
b. The class and instance methods of the subclasses
c. Instances of the class and instances of any subclasses
d. All the above
20. A collection where all additions to the collection are made at the end, but
all deletions are made at the beginning is called:
a. Queue.
b. Stack.
c. Array.
d. Sorted Collection.
21. Which of the following will be included in the ordered collection returned from evaluating the
expression: LimitedPrecisionReal allSubclasses
a. SmallInteger
b. LargeInteger
c. Integer
d. Float
22.To evaluate an expression or expression series a fixed number of times you should use:
a. timesRepeat:
b. whileTrue: or whileFalse:
c. ifTrue:ifFalse:
d. Do:
24. Consider a set with 4 elements: 3, 5, 7, 8. If we add two elements: 4 and 8 then the set:
a. gets a new size of 5 elements: 3, 5, 7, 8, 4.
b. gets a new size of 6 elements: 3, 5, 7, 8, 4, 8.
c. gets a new size of 2 elements: 4, 8.
d. will not be changed since you can't add elements to sets.
25. The type of software testing that depends only on the specification of the software is called:
a. Black-box testing
b. Implementation-based testing
c. White-box testing
d. Gray-box testing
7
FORM A
8
FORM A
Part 2(8 questions) [48 marks]
Instructions: Answer the following 8 short questions. Each question is worth 6 marks.
You should answer all questions of Part 2.
Affordance:
Internet:
Domain model:
Q2) Consider the following object-interaction diagram where the variables toad1 and toad2 both
reference instances of the Toad class.
9
a. Extract the expression series for the object-interaction diagram above.
.........................................................................................................................................
.........................................................................................................................................
.........................................................................................................................................
.........................................................................................................................................
Q3) For each of the following message expressions, write down the required information. Note that
frog1 is in its initial state.(position -->1, colour -->Green)
a. frog1 position
Receiver: ........................................................................................................................
Message: ........................................................................................................................
Message selector: ............................................................................................................
Argument: .......................................................................................................................
Message answer: .............................................................................................................
Textual representation of the message answer: ...................................................................
.......................................................................................................................................
10
c. Dialog warn:'Good luck'
Receiver: ....................................................................................................................
Message: ....................................................................................................................
Argument(s): ...............................................................................................................
...................................................................................................................................
(a) What are the values of x and y at the end of the first iteration?
(b) What are the values of x and y at the end of the last iteration?
Q5) Draw the class hierarchy diagram that represents the relation between the Shape,
Rectangle, Circle, Square, Four_edged_shape. The Four_edged_shape is a template class
for objects of shapes that have four edges.
11
Q6) (a) Define the following terms:
.....................................................................................................................
Affordance:
.....................................................................................................................
.....................................................................................................................
Usability:
.....................................................................................................................
1. ......................................................................................................................................
2. ......................................................................................................................................
Q7) (a) Briefly explain the difference between abstract class and concrete class giving one example on
each one.
.............................................................................................................
Abstract class:
.............................................................................................................
Example: .............................................................................................................
.............................................................................................................
Concrete class:
.............................................................................................................
Example: .............................................................................................................
(b) How many concrete classes are there to represent integer numbers? Briefly explain why?
..........................................................................................................................................
..........................................................................................................................................
12
Q8) (a) Briefly explain the difference between abstract methods and base methods giving one example
on each one.
.............................................................................................................
Abstract method:
.............................................................................................................
.............................................................................................................
.............................................................................................................
Example: .............................................................................................................
.............................................................................................................
Base method:
.............................................................................................................
.............................................................................................................
.............................................................................................................
Example: .............................................................................................................
(b) Briefly explain the difference between instance variables and class variables in terms of
scope.
............................................................................................................
Instance variable:
............................................................................................................
............................................................................................................
............................................................................................................
............................................................................................................
13
FORM A
Question 1: (a) For the sentences in the table below, write down the most appropriate message
selector from the protocol of the Dialog class to be used.
(b) Write expression series to calculate the average temperature for a week (7 days) according to
the following specifications:
1. Prompt the user to enter each day temperature, one at a time, in a dialog box.
2. Check that the temperature entered by the user is between 0 and 50 inclusive, otherwise,
display a dialogue box with the message 'Invalid temperature', and exit.
3. Calculate the average temperature for the week and display it in a dialogue box.
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
14
Question 2: (a) Quizzes grades for three students are to be stored in arrays of numbers. Write an
expression series to create three arrays: student1Quizzes, student2Quizzes &
student3Quizzes), each consists of three elements. Then use at:put: (or any other way
you've learned) to add the data of the 3 quizzes in the corresponding array according to the table
below:
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
(b) Write expression series to create a dictionary studentDictionary using students' names
as keys and the quizzes arrays as the values according to the table below:
Key Value
'Ahamd' student1Quizzes
'Omar' student2Quizzes
'Sami' student3Quizzes
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
Question 3:
15
1. Suppose that ‘foo’ is an instance of class ‘Aliens’ as indicated in the following
variable reference diagram. Debug the following piece of code, find the four
errors and correct them without deletion.
Class: Aliens
colour Black
foo height 10
weapon ‘bombs’
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
2. Write a piece of code that will assign a grade to a student, based on his final
score. The code reads the score from a dialog and returns the grade. Assume the
following grade distribution table:
16