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: http://download. oracle. com/javase/7/docs/api/ 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 Name 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. Start 137? 138 140 false true 141? 143 145 true 146 false End Page 2 Name Student No Question 2. Inter-method Control Flow (Call Graph) [7 points] Draw a call graph starting from the IntIterator edgeRows(int node) ethod defined in the Graph class of the prefuse. data 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 prefuse. data. util or any class in a package starting with prefuse. data. column 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.
The Essay on An Inspector Calls Class Business Play
Priestley wrote an Inspector Calls in 1945 - just before the end of WWII. However, The play itself is set in 1912 - just before the start of WWI, and in Edwardian England. Priestley was a socialist writer who had left wing political views with very strong beliefs; he enjoyed using types of theatre to get his messages across. When the platy was set, there was a lot of historical events going on at ...
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 Name 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 getX( getY() Rectangle(x, intersects(boundingRect2) oid 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 Name Student No Question 4. Types, Method Overriding and Method Overloading. [7 points] Using the definitions of classes given in the prefuse. visual and prefuse. data 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. asColumn(“foo”); // Parameter added during exam VisualGraph vg1 = new VisualGraph(); vg1. fireGraphEvent(t, 1, 2, 3, 4); VisualTupleSet vts = vg1; Visualization v = vts. getVisualization(); i) [1 point] Is the line of code labeled (1) above a legal Java statement (i. e. , does it compile)? Why or why not? No. VisualGraph is a subtype of Graph. We can assign an object of the subtype to a variable declared as the supertype but not vice versa as this statement attempts. ii) [1 point] Is the line of code labeled (2) above a legal Java statement (i. e. , does it compile)? Why or why not?
The Essay on Java Programming: Mutator Method Assignment Q&A
On paper, write a method called sum with a while loop that adds up all numbers between two numbers a and b, inclusive, and returns the sum as its result. The values for a and b can be passed to the sum method as parameters. For instance: sum(1, 5) would return the value 15 (i.e., 1 + 2 + 3 + 4 + 5). What happens if the value of the second parameter is less than the value of the first? public int ...
Yes. VisualTable is a subtype of Table and an assignment of an object of a subtype to a variable declared as a supertype is allowed. iii) [1 point] Considering the lines of code labeled (4) and (6) above, what is the apparent type of vg1 at the line of code labeled (6)? VisualGraph iv) [1 point] Considering the lines of code labeled (4) and (6) above, what is the actual type of vts after the line of code labeled (6) executes? VisualGraph Page 6 Name Student No v) [1 point] State the name of the class and the full method signature of the method executed on the line of code labelled (3).
In CascadedTable … protected boolean hasColumn(String) vi) [1 point] State the name of the class and the full method signature of the method executed on the line of code labeled (5).
In VisualGraph … protected void fireGraphEvent(Table, int, int, int , int) vii) [1 point] Is the line of code labeled (7) above a legal Java statement (i. e. , does it compile)? Why or why not? Yes, VisualTupleSet declares a getVisualization() method. Page 7 Name Question 5. Unit Testing [5 points] Student No Consider the following specification for methods of the EvenIntegerSet class. ublic class EvenIntegerSet { /** * Constructor * EFFECTS: An empty EvenIntegerSet is created */ public EvenIntegerSet() {…} /** * Add an even integer into the set * REQUIRES: anInteger is an even number and anInteger > 0 * MODIFIES: this * EFFECTS: if anInteger is even and not contains(anInteger) * then anInteger is added to the set, otherwise set remains * the same */ public void add(int anInteger) { …} /** *
Determine if a given integer is in the set * EFFECTS: returns true if anInteger is in set, false otherwise */ public boolean contains(int anInteger) {…} /** * Return a list of all integers in the set * EFFECTS: returns a list of all integers in a set; an empty * list is returned if the set is empty */ public List getListOfIntegersInSet() {…} } Provide the input and output for five test cases needed to test the EvenIntegerSet class according to its specification. Each test case should cover a different condition (i. e. , five test cases that test the same thing will not count for separate marks. ) For each test case, you can assume a new EvenIntegerSet object, referred to through a variable named aSet, is created at the start of the test case. e. g. , EvenIntegerSet aSet = new EvenIntgerSet(); Describe which method calls are needed in the test case and what outputs are expected. You should try to write Java code, but written natural language answers are also acceptable. Page 8 Name Student No
The Essay on Dress Codes
Wow, Mrs. Nettie thats a great dress youre wearing today, said Merilee as she walked through the cafeteria towards the rest room. Not ten minuets later Sarah walked past the office wearing a dress almost identical to Mrs. Netties, only to be stopped by the principal Mr. Meth. Sarah was forced to change, because her dress was not following the school dress policy, Mrs.Nettie did not have to change. ...