final - CSE 142, Winter 2008 Final Exam Wednesday, March...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 of 9 CSE 142, Winter 2008 Final Exam Wednesday, March 19, 2008 Name: ___________________________________________ Section: ___________________ TA: ___________________ Student ID #: ___________________ Rules: You have 110 minutes to complete this exam. You may receive a deduction if you keep working after the instructor calls for papers. This test is open-book/notes. You may not use any computing devices of any kind including calculators. Unless otherwise indicated, your code will be graded on proper behavior/output, not on style. You do not need to write any import statements in your exam code. Please do not abbreviate any code, such as writing "ditto" marks or dot-dot-dot marks ... The one abbreviation that is allowed for this exam is to write S.o.p for System.out.println . If you enter the room, you must turn in an exam and will not be permitted to leave without doing so. You must show your Student ID to a TA or instructor for your submitted exam to be accepted. Good luck! Problem Description Earned Max 1 Expressions 10 2 Array Mystery 15 3 Inheritance Mystery 15 4 File Processing 15 5 Array Programming 10 6 Array Programming 10 7 Critters 15 8 Objects and Classes 10 X Extra Credit +1 TOTAL Total Points 100
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 of 9 1. Expressions (10 points) For each expression in the left-hand column, indicate its value in the right-hand column. Be sure to list a constant of appropriate type and capitalization. e.g., 7 for an int , 7.0 for a double , "hello" for a String , true or false for a boolean . Expression Value 102 / 20 / 2.0 * 2 + 100 / 30 / 2 27 % 4 + 6 % 6 + 5 % 20 "\"" + (3 + 3 * 3 + "" + 3 + 3 * 3 + "\"") !(42 > 10 && (2 > 3 || 4 < 5)) (2 == 3) == (4 == 5) _____________________________ _____________________________ _____________________________ _____________________________ _____________________________ 2. Array Mystery (15 points) Consider the following method: public static void arrayMystery(int[] a) { for (int i = a.length - 1; i >= 0; i--) { if (a[i] == a[a.length - i - 1]) { a[i]++; a[a.length - i - 1]++; } } } Indicate in the right-hand column what values would be stored in the array after the method arrayMystery executes if the integer array in the left-hand column is passed as a parameter to it. Original Contents of Array Final Contents of Array int[] a1 = {1, 8, 3, 8, 7}; arrayMystery(a1); int[] a2 = {4, 0, 0, 4, 0, 0, 4, 0}; arrayMystery(a2); int[] a3 = {9, 8, 7, 6, 4, 6, 2, 9, 9}; arrayMystery(a3); int[] a4 = {42}; arrayMystery(a4); int[] a5 = {5, 5, 5, 6, 5, 5, 5}; arrayMystery(a5); _____________________________ _____________________________ _____________________________ _____________________________ _____________________________
Background image of page 2
3 of 9 3. Inheritance Mystery (15 points) Assume that the following classes have been defined: public class Brian extends Lois { public void b() { a(); System.out.print("Brian b "); } public String toString() { return "Brian"; } } public class Lois extends Meg { public void a() {
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/08/2008 for the course CSE 142 taught by Professor Martystepp during the Winter '07 term at University of Washington.

Page1 / 9

final - CSE 142, Winter 2008 Final Exam Wednesday, March...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online