Computer Science - Software Construction Midterm

Topics: Object-oriented programming, Java, Method Pages: 9 (1717 words) Published: May 26, 2013
The University of British Columbia
CPSC 210 Midterm Examination February 8, 2012 - SOLUTIONS Time: 90 minutes Name (PRINT) (Last) (First)


Student No____________________________Signature


This examination has 12 pages. Check that you have a complete paper. Ensure you have access to the source repository that will be specified on the whiteboard. You may access this repository before you are told you can start the exam. We refer to the code in this repository as Prefuse in this exam. The only software authorized for use on this exam is Eclipse (with the Subclipse plugin) accessing the code we provide for the midterm and a web browser. The web browser may be used only to view the online Java 7 API available at: Answer all questions on this paper. Give short but precise answers. Work fast and do the easy questions first. Leave some time to review your exam at the end. The marks for each question are given in []. Use this to manage your time. Good Luck

Question 1 2 3 4 5 6 TOTAL

Marks /7 /7 /6 /7 /5 /6 /38


Student No

IMPORTANT: Questions 1, 2 and 4 apply to the prefuse system provided in the specified repository. Question 1. Intra-method Control Flow (Flowchart) [7 points] Draw a flowchart for the void clearAggregateMappings(int row, boolean update) method defined in the AggregateTable class of the prefuse.visual package.



140 false true 141‐143

145 true 146 false


Page 2


Student No

Question 2. Inter-method Control Flow (Call Graph) [7 points] Draw a call graph starting from the IntIterator edgeRows(int node)

method defined in the Graph class of the package.

Do not include calls to methods
    in any Java library (where the packages starts with java.) or any class in a package starting with or any class in a package starting with or any class in a package starting with prefuse.util

Remember to include both the name of the type and the name of the method for each call. If a method is overloaded, provide the types of the parameters to identify exactly which method might be called. If you abbreviate any names, please provide a legend. You can answer this question on the next page. You might want to rotate the page and draw your graph in landscape mode.

Page 3


Student No
Graph  edgeRows(int)

Graph  edgeRows(int int)

Graph  getInDegree(int) Table  get (int, String) Graph  getOutDegree(int)

Table  getInt(int, String)

Table  getColumnNumber(String)

Table  getColumn(int)

Table  getColumnRow(int, int)

Page 4

Name Question 3. UML Sequence Diagram [6 points]

Student No

Consider the UML Sequence Diagram given below. Write as close to Java code as you can to describe the implementation of the method collideWith(Sprite other)on an Invader object that is described by this diagram. You may need to assume where there are likely return values from calls to methods. Handle these return values in the code you sketch. You can add comments to explain your code. We will not be grading for correct Java syntax. invader:   Invader collideWith  (Sprite other) Rectangle( boundingRect1:   Rectangle boundingRect2:   Rectangle other:   Sprite





void collideWith(Sprite other) { Rectangle boundingRect1 = new Rectangle(); int x = other.getX(); int y = other.getY(); Rectangle boundingRect2 = new Rectangle (x, y); intersects(boundingRect2); }

Page 5


Student No

Question 4. Types, Method Overriding and Method Overloading. [7 points] Using the definitions of classes given in the prefuse.visual and packages, consider the following code (which may or may not be legal Java code): (1) (2) (3) (4) (5) (6) (7) VisualGraph vg = new Graph(); Table t = new VisualTable(); boolean b = t.hasColumn(“foo”);...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Essay about computer science
  • COmputer science Essay
  • Computer Science Essay
  • Computer Science Essay
  • Computer Science Essay
  • Computer Science Research Paper
  • Computer Science cover letter Essay
  • computer Essay

Become a StudyMode Member

Sign Up - It's Free