You are on page 1of 11

CS314 Fall 2011 Test 1 Solution

Part 1: Multiple Choice; True/False questions (4 questions; 10 points)


1. (5 points) State whether the following statements are TRUE or FALSE (circle either TRUE or
FALSE).
a. If a superclass declares an abstract method, every subclass, irrespective of whether they
are concrete or abstract, must implement that method.

TRUE FALSE (not true when the subclass is abstract!)

b. A method in a subclass that redefines a method in a superclass (i.e., the signatures of


the methods are the same, but the method bodies are different) is said to be
overloaded in the subclass.

TRUE FALSE (this is overriding, not overloading)

c. An object of a class that implements an interface may be thought of as an object of that


interface type.

TRUE (see notes on OOP review) FALSE

d. In the Unified Process (UP) timeboxing means that a team cannot extend the time spent
in an iteration when developers are having problems implementing a feature.

TRUE (see notes on processes) FALSE

e. The iterative/incremental process model is more radical than the waterfall process
model.

TRUE (see notes on processes) FALSE

2. (1 point) What is the primary goal of the software requirements activity?


a. To understand the solution that will be implemented in a programming language.
b. To identify the test cases that will be used to test code.
c. To understand and precisely document a problem that a software solution will address.
d. To produce a model of the solution that can be used as a guide to write code.

3. (1 point) What is the primary goal of the software design activity?


a. To test a program.
b. To understand and describe a solution that will be implemented in a programming
language.
c. To precisely model the requirements of a software system.
d. To find errors in a customer’s requirements statement.

4. (3 points) The following is an inheritance structured implemented in Java:

Object

equals(o:Object):Boolean

Automobile

equals(o:Automobile): Boolean
equals(o:Object): Booleans

Given the following declarations:


Object obj = new Object();
Automobile auto1 = new Automobile();
Object auto2 = new Automobile();

circle which equals() methods is called for each call given below
a. auto1.equals(obj);

equals(o:Object) in Object

equals(o:Object) in Automobile

equals(o:Automobile) in Automobile

b. auto2.equals(obj);

equals(o:Object) in Object

equals(o:Object) in Automobile

equals(o:Automobile) in Automobile

c. auto1.equals(auto2);

equals(o:Object) in Object

equals(o:Object) in Automobile

equals(o:Automobile) in Automobile
Part 2: Short answer questions (4 questions; 30 points)

1. (4 points) For each of the following associations, indicate whether it should be a plain
association (Assoc), or composition/strong aggregation (Comp) – indicate only one (They can all
be modeled as plain associations, but no marks will be given if you indicate Assoc but the
association is more accurately represented by a composition). Justify your answer in each case;
if your justification is wrong then your entire answer is wrong.

a. An organization and its employees Assoc Comp

Justify: If an organization is deleted its employees are not. If you selected Comp then
you have to rationalize why employees are deleted when an organization is deleted
(e.g., you can argue that employee is a role, not a person, that is owned by the
company and thus is deleted when the organization is deleted)

b. A file and its contents Assoc Comp

Justify: When a file is deleted its contents are also deleted. If you circle Assoc you will
have to justify why the contents are not deleted.

2. (This question will appear in a future quiz) The following are examples of classes in the design
of an Airport Management System (AMS). Circle the strongest form of cohesion that each class
has. Justify your answer in each case; if your justification is wrong then your entire answer is
wrong.

a. A class that has a method that reads and parses the input file used to create the initial
Airport System, and also a method that displays the user interface for entering seat
bookings.

COINCIDENTAL COMMUNICATIONAL FUNCTIONAL

Justify:

b. A class that reads and parses the input file used to create the initial Airport System.

COINCIDENTAL COMMUNICATIONAL FUNCTIONAL


Justify:

3. (This question will appear in a future quiz) State what type of coupling the following module
relationships have (Circle the strongest form of coupling that applies):
a. An object calls the method calculateWitholdingTax(employeeRecord) defined in another
object, but only part of the employer record is actually used in the tax computation
method that is called.

Content Common Control Stamp Data

Justify:

b. Module p calls module q, and q passes back a flag that forces p to print an error
message.

Content Common Control Stamp Data

Justify:

4. (10 points) How does data abstraction differ from functional abstraction? Give an example of each
type of abstraction in your answer. (Please write legibly; if we cannot understand your handwriting
you will get 0 for this question)

In data abstraction the form or representation of the data is abstracted out, that is, a user of the
data does not how the data is represented, the user knows about the data only through the
operations that manipulate it. In functional abstraction the implementation of an operation is hidden
from the user, that is, a user does not have knowledge of how a method is implemented.
Part 3: Modeling questions (4 questions; 60 points)
1. (20 points) An organization has three categories of employees: professional staff, technical staff
and support staff. The organization also has departments and divisions (collectively called
organization units). Each employee belongs to exactly one department or exactly one division (an
employee cannot belong to a department and a division). An employee can change his or her
category over time. At any given time, an employee must be in one of the three categories.
Complete the class model describing the above given below. You will need to add new classes and
relationships. You must include role names and multiplicities on each end of an association. You
do not need to include navigability symbols on association ends.

Organiztion

org 1

units *

1 * * 1 Organization
Status Employee
status emps Unit
employees empUnit

Division Department

Professional Techical

Support
2. (20 points) The following is a design class model of a car registration system created by a
novice modeler. The following methods are included in the design:
Point out all the deficiencies and bad practices in the model (do not give missing
operations, missing attributes, bad operation, variable, role names as part of your
answer). Draw an improved design class model. You can show only the operation names in
the diagram you draw – no need to show parameter values or return values since these
should not change from the original model. State any assumptions you make (points will
only be awarded for reasonable assumptions). Space is provided on the next page for your
diagram.

Vehicle Registration Manager

registerVehicle(driverLicID: String, vehicleID:Integer)


findDriver(driverLicID:String): Driver
Operations in findVehicle(vehicleID:Integer): Vehicle
Manager need
access to Driver driverManager carManager
1 1

What if a driver
drivers has multiple
* licenses (for
multiple vehicles
driverLicID is Driver *
vehicles)? This vehicleID is
unique to a driver
information unique to a
name: String should be placed Vehicle vehicle
driverLicID:String in a separate
vehicleLicenseNum: String class. vehicleID:Integer
vehicleRegistrationTax: Integer make: String
vehiclesOwned: List Vehicle year: String
homeAddr1, homeAddr2: Address driverName:String
workAddr1, workAddr2: Address Visually better to
getDriver():Driver
represent this
createVehicle(vehicleID:Integer)
Visually better to relationship as an
Multiple association
addresses that represent this
could change; reference as an
better to make a association
class called
Address with an
association to
Driver
Draw the modified diagram for Question 2 below the original diagram (show all multiplicities and
navigability symbols in your answer; remember to put role names on all association ends):
Vehicle Registration Manager

registerVehicle(driverLicID: String, vehicleID:Integer)


findDriver(driverLicID:String): Driver
findVehicle(vehicleID:Integer): Vehicle

driverManager carManager
1 1

drivers
*

driverLicID is Driver * vehicles


vehicleID is
unique to a driver
unique to a
name: String Vehicle vehicle
driverLicID:String
0..1 vehicleID:Integer
1..*
make: String
primaryDriver ownedVehicles year: String

licDriver getDriver():Driver
createVehicle(vehicleID:Integer) 1
licVeh
1
hdrivers
* *
wdrivers
1..* lic
licenses 0..1

1..* Vehicle License Information


homeAddrs

workAddrs vehicleLicenseNum: String


Address vehicleRegistrationTax: Integer
1..*
3. (10 points) Redraw the following as a class model without association classes.

customer bookedSeats
Customer AirlineSeat
0..30 0..20

Booking

reservedDate:Date

1 seatBookings bookings 1
Customer Booking AirlineSeat
cust 0..20 0..30 seat
4. (10 points) The following is part of a design class model of a video rental system. In the
system, video outlets stock copies of videos. Each outlet maintains a catalog of video
descriptions. Each copy stocked by an outlet has a description in the outlet’s catalog. A
customer can rent 0 or more video copies from any outlet.

renter rentedCopies
0..1 *

*
Customer videoCopy
stocks

1 located-in copies
*

VideoOutlet

1
description
1..* cataloged-in

1..* VideoDescription
CONSTRAINT: A video
copy located-in a video outletVideos
title
outlet must have a
description cataloged-in the
same video outlet

For each of the two (2) object models given below state whether it is valid or not with respect
to the above class model. If the object model is invalid circle all the elements (objects, links)
that violate constraints in the class model (e.g., an association multiplicity constraint or the
constraint associated with VideoOutlet) and describe the constraint violated. Please note that
VideoOutlet has a constraint on it “A video copy located in a video outlet must have a
description cataloged in the same video outlet”. This constraint must be satisfied by valid
object diagrams.
Object Model 1 INVALID
outlet1:VideoOutlet outlet2:VideoOutlet

desc1:VideoDescription
desc2:VideoDescription desc3:VideoDescription

vid1:VideoCopy vid2:VideoCopy vid3:VideoCopy

cust1:Customer cust2:Customer

Video copy can


be checked out
by at most 1
customer

The class model is repeated here for your convenience


renter rentedCopies
0..1 *

*
Customer videoCopy
stocks

1 located-in copies
*

VideoOutlet

1
description
1..* cataloged-in

1..* VideoDescription
CONSTRAINT: A video
copy located-in a video outletVideos
title
outlet must have a
description cataloged-in the
same video outlet

Object Model 2 INVALID


outlet1:VideoOutlet outlet3:VideoOutlet outlet2:VideoOutlet

Copy not desc1:VideoDescription


associated with desc2:VideoDescription desc3:VideoDescription
an outlet

vid1:VideoCopy vid2:VideoCopy vid3:VideoCopy

Copy not
associated with
outlets that do not
have a
cust1:Customer cust2:Customer description for the
video

You might also like