Question: JAVA 2.2 Show the value of x after this statement: double x = 1/2; Code State int i = j; i = int j =
JAVA
2.2 Show the value of x after this statement: double x = 1/2;
| Code | State |
| int i = j; | |
| i = | |
| int j = 2; | |
| i = j= | |
| while(i < j) { | |
| i = j= | |
| i = i * i +1; | |
| i = j = | |
| j = j+2; | |
| i = j = | |
| } | |
| i = j = |
(20 points) 4.1. (15 points) Write the body of this method. i =
/**
* Returns the smallest value in a. *
* @param a * an array of ints
* @return smallest value in the array a
* @requires * a.length >= 1 * @ensures * minimum = [the smallest value in a] */
private static int minimum(int[] a) { }
4.2. (5 points) Clearly and concisely explain why the precondition is important here.
5. (10 points) Trace the effect of the line of code below that calls squareAndReset by tracing the execution of the method body of squareAndReset for this call.
Tracing table for the call:
| CODE | State(Values) |
| num = 13.0 | |
| double sq = squareAndReset(num); | |
| num = sq = |
| Code | State |
| private static double squareAndReset (double x) { | |
| x = | |
| double square = x * x; | |
| x = square = | |
| x = 0.0; | |
| x = square = | |
| return square; } |
7. (9 points) The following is a valid XML document. Sunny with 90% probability of football
7.1. (8 points) Draw the XMLTree associated with this document. (Dont worry about drawing the tag icon; just include the enclosing brackets <...> for each label that is a tag.)
7.2. (1 point) How many children does the root node of this XMLTree have?
8. (6 points) The following is not a valid XML document. Circle the locations of three nonoverlapping errors that make it invalid, briefly explaining each error in the space below.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
