This preview shows pages 1–4. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CSE 114 Practice Midterm Exam 2 Thursday, October 21, 2004 NAME (please print legibly): Your University ID Number: NO BS bonus: If you do not know the answer to a problem and leave it blank you will receive 1 point for each subpart (e.g., a,b,c, etc.) that you leave blank. If you write anything in the space and it is wrong, you will receive a zero. Thus, the score for a completely blank exam is 12. You will not lose any points for small coding details such as misspelling a method name, leaving out some default method arguments, or getting the order of method arguments wrong. QUESTION VALUE SCORE 1 10 2 25 3 15 4 10 5 20 6 15 TOTAL 95 1 1. (10 points) Write a recursive method sum() that computes the sum of the numbers from 1 to n using the following recursive definition: the sum of 1 to n is equal to the sum of 1 to ( n /2) plus the sum of ( n /2 + 1) to n. public int sum (int a, int n) { } 2 2. (25 points) (a) Define a class GradStudent that represents a student enrolled in a graduate program. In(a) Define a class GradStudent that represents a student enrolled in a graduate program....
View
Full
Document
 Spring '08
 TASHBOOK

Click to edit the document details