Anda di halaman 1dari 6

# ARAB OPEN UNIVERSITY

## FACULTY OF COMPUTER STUDIES

INFORMATION TECHONOLGY AND COMPUTING
M206: Computing: An Object–Oriented Approach
FALL 2006/2007

## Solutions for Midterm Exam Forms A

Part 1 (A: 1 marks for each , B: 2 marks for each) Total of 60 marks
FORM A

## Part (1) A Part (1) B

1 F 1 A
2 T 2 D
3 F 3 C
4 F 4 A
5 T 5 B
6 T 6 B
7 F 7 D
8 T 8 B
9 T 9 B
10 F 10 A
11 C
12 C
13 D
14 D
15 B
16 C
17 C
18 D
19 D
20 A
21 D
22 A
23 C
24 A
25 A
Part 2: (total of 48 marks, 6 marks for each question)

## Q1. Definitions (1 mark for each)

User interface: the hardware and software components that allow the user to
communicate with the computer.
Affordance: The features of an object which make it self-apparent how the
object should be used.

Internet: a system that has both hardware and software components, which
allow data to be exchanged and processing tasks to be distributed.

## Domain model: The software objects and messages passing between them

which make up the program.
Q2. Consider the following object-interaction diagram where the variables toad1 and toad2
both reference instances of the Toad class.

ANS:
x2 := x1 + 5.
b. account2 balance: (account1 balance) + 500

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)

ANS:
The message: position
The message selector: position
The argument (s):No arguments
The texual representation of the message answer: 1
b. The receiver object evaluated to: false
The message: ifFalse:[frog1 brown. frog1 left]
The message selector: ifFalse:
The argument: [frog1 brown. frog1 left] or Block object
The texual representation of the message answer: An instance of class Frog (position 0,
colour Brown)
The message: warn:'Good luck'
The message selector: warn:
The argument (s):'Good luck'
The texual representation of the message answer: nil
Q4. Given the following expression series:
| x y |
x := 1.
y := 9.
[y >= 3] whileTrue:[x := x + y.
y := y - 3]

ANS:
(a) x = 10, y = 6.
(b) x = 19, y = 0.

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

Shape

Four_edged_shape Circle

Square Rectangle

Q6: ANS:
Affordance: The degree to which it is obvious to the user how to operate the control.
A key principle of HCI that states that the appearance of any control should
suggest its functionality.
Usability: How easy a system is to learn and use.

## Name two requirements of the user needs analysis

1. User characterization.
2. Task analysis. ( 2 points are required only)
3. Situational analysis.
Q7. (a) Briefly explain the difference between abstract class and concrete class giving one
example on each one.

ANS:
(a)
abstract class: This is a class which should never have instances, rather it is used to specify
the minimum set of messages to which any subclass (of the abstract class) can
respond.
An abstract class describes the common characteristics of its subclasses.
Example: Amphibian, Object, Magnitude, Number, Integer,...
concrete class A class of which instances are created.
Example: Frog, Toad, HoverFrog, Account, SmallInteger, ...
(b)
There are 3 concrete classes to represent integers.
Reason: efficiency of speed of execution and of memory usage .

Q8. (a) Briefly explain the difference between abstract methods and base methods giving one
example on each one.

ANS:
(a)
Abstract A method which does not implement the required behaviour and requires the
method: subclasses to provide their own implementations by overriding the abstract
method. An abstract method will normally contain the code ^self
subclassResponsibility.
Example: home and left in the class Amphibian and the methods < and = in the
class Magnitude
Base method A method which is fully implemented in the abstract class and can be
inherited and used in subclasses as it stands.
Example: brown, green, colour, colour:, position, position: in the
abstract class Amphibian.
(b)
Instance Instance variables can only be directly accessed from the methods of the
variables: class in which they are defined and from the methods of its subclasses.
Class variables are visible to and can be used directly by the class and
Class variables: instance methods of the class, its subclasses, instances of the class and
instances of any subclasses.
Part 3: (total of 42 marks, two questions to be selected, 21 marks for
each question)

Question 1.

ANS:
a.

## b. |temperature sum average|

sum:=0.
average:=0.
7 timesRepeat:[ temperature:= (Dialog request:'Enter the
temperature: '
((temperature>=0) &(temperature<=50 ))
ifTrue: [sum:=sum+temperature]
ifFalse:[^Dialog warn:'Invalid
temperature']
].
average:=sum/7.
Dialog warn:'Average temperature is: ', (average
printString)

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:

## Array Quiz1 Quiz2 Quiz3

student1Quizzes 80 90 77
student2Quizzes 95 95 99
student3Quizzes 72 60 55

ANS:
(a) student1Quizzes := Array new: 3.
student1Quizzes at: 1 put: 80; at: 2 put: 90; at: 3 put:
77.
student2Quizzes := Array new: 3.
student2Quizzes at: 1 put: 95; at: 2 put: 95; at: 3 put:
99.
student3Quizzes := Array new: 3.
student3Quizzes at: 1 put: 72; at: 2 put: 60; at: 3 put:
55.
OR:
student1Quizzes := #(80 90 77).
student2Quizzes := #(95 95 99).
student3Quizzes := #(72 60 55).
(b) studentDictionary := Dictionary new.
studentDictionary
at: 'Omar' put: student2Quizzes;
at: 'Sami' put: student3Quizzes

## Question 3 (21 marks):

Ans:
1. (8 marks, 2 marks for each)
a. In the first line, aliens should be Aliens (with capital letter) as the class
name in the variable reference diagram appears.
b. In the first line, new should be after Aliens not before it.
c. In the third line, “.” Is missing.
d. In the last line, the keyword message selector concatenate: lacks its
colon “:” in the forth line.