S A M P L E CPS 1 (Ramm) Spring 1998 11 February 1998 Quiz #4 Name ___________________ Honor Code________________________ Section _____ (Note: Getting your Name and Section right is worth one point. If we can't decipher your name or section, it's wrong.) A. Assume you have the following Java code fragment (part of the action method) and it runs. What is the value of sum when it completes? int sum = 0, k, start = 2, stop = 7; ... k = start; while (k < stop) { k = k + 3; sum = sum + 2*k; } ... B. Here are some simple rules defining Java syntax. #1 ==> //a sequence of letters and/or digits that begin with a letter// #2 ==> = ; #3 ==> #4 ==> #5 ==> #6 ==> "//any string of printable characters//" #7 ==> + #8 ==> { // a sequence of 's // } In the style shown in the lectures, show how these rules can be used to generate the following Java program fragment (thus verifying that it is syntactically correct. Identify the rule used at each stage. Continue on back as needed. { j = "victory!"; s = "good" + msg; } Start with: #8 ==>