Sample Exams Sample Exams For preparing for exams in this class, we recommend you work lots of problems, under exam-like conditions. Other sources of sample problems: the exercises worked in lecture unofficial homework given in lecture the textbook exercises problems from the lab assignments make up your own problems to test yourself (or your friends -- study groups can be very helpful) codingbat.com. Has lots of Java array, string, and recursion practice problems you can solve on the web. Practice It! (from University of Washington) also has lots of practice Java problems you can solve on the web (requires creating an account to get solutions tested). The About page also has links to some other similar tools / practice problem sets. Exams in this course may involve coding with Java API classes, classes we have written or used in lectures, labs, or assignments, or other classes specific to the exam. You are not expected to memorize the syntax of the whole interface to such classes, but rather, on a real exam, would be given the relevant parts of the interface (see "code handouts" on sample exams below for examples of this). However, I expect you to know the syntax for doing the common things with the Java classes we have worked with a fair amount: Java classes and methods you need to know for exams: String (length, +, equals, initializing them) ArrayList (get, set, add, size), System.out (print, println) Scanner (initializing with System.in, next, hasNext, nextInt, hasNextInt, etc., nextLine). These are closed-book, closed-note exams, done with pencil and paper so you do need to be able to write basically syntactically correct Java code. However, we won't be picky about semi-colons and such on code that's not going through a compiler. We won't be checking style per se. That said, your indentation and curly brackets should make the block structure of your code clear. Also, using good variable names will help you (as well as us) understand what you are trying to do in your code. (We understand that with time constraints you won't want to use very long variable names.) Your exams this semester will have questions similar to the previous ones provided here. Because of COVID, classes were all online for a while, so Spring 2020 MT 2, though Spring 2021 Final Exam are in an online format instead: solutions were typed rather than handwritten, but the types of exam questions were largely the same as for the printed exams. Final exam What's covered: The final exam is cumulative, so all course material through the last lecture is included. Also, any of the previously published sample problems or actual problems from the midterms will be useful practice material, as well as the problems on the old final exams below. Note: No prepared solutions available here. For those problems whose answers you are unsure of after you have worked the problem, and even after looking up the relevant material, you can go over them with your study group, or get help in staff office hours. Also, we are holding a review session (see piazza for date/time) where we will go over problems by request. Sample final exam questions Fall 2022 Final Exam (pdf) Code handout for Fall 2022 Final (pdf) Spring 2022 Final Exam (pdf) Code handout for Spring 2022 Final (pdf) Fall 2021 Final Exam (pdf) Code handout for Fall 2021 Final (pdf) Spring 2021 Final Exam (pdf) Code handout for Spring 2021 Final (pdf) Fall 2020 Final Exam (pdf) Code handout for Fall 2020 Final (pdf) Spring 2020 Final Exam (pdf) Code handout for Spring 2020 Final (pdf) Fall 2019 Final Exam (pdf) Code handout for Fall 2019 Final (pdf) Spring 2019 Final Exam (pdf) Code handout for Spring 2019 Final (pdf) Fall 2018 Final Exam (pdf) Code handout for Fall 2018 Final (pdf) Spring 2018 Final Exam (pdf) Code handout for Spring 2018 Final (pdf) Fall 2017 Final Exam (pdf) Code handout for Fall 2017 Final (pdf) Spring 2017 Final Exam (pdf) Code handout for Spring 2017 Final (pdf) Fall 2016 Final Exam (pdf) Code handout for Fall 2016 Final (pdf) Midterm 2 What's covered: The exam will emphasize topics that have been covered since the first Midterm. However, those topics build on the material from before that, so that material is relevant too. Sample midterm 2 exam questions Note: Occasionally there are is a mistake on an exam (or solution) whose correction was announced at the exam; they don't tend to get fixed on these documents later since I don't reuse exams. Note: Some of the following sample exams also have solutions provided. Reviewing an old exam and its solution is not a very effective way to prepare for an upcoming exam. A better way is to take the sample exam under exam-like conditions: closed book, closed note, with a time limit. Once you have completed the exam you can use the posted solution, if available, to check your answers. For those problems whose answers you are unsure of after you have worked the problem, and even after looking up the relevant material, you can go over them with your study group or get help in staff office hours. Fall 2022 Midterm 2 (pdf) Code handout for Fall 2022 MT2 (pdf) Solution for Fall 2022 MT 2 Spring 2022 Midterm 2 (pdf) Code handout for Spring 2022 MT2 (pdf) Fall 2021 Midterm 2 (pdf) Code handout for Fall 2021 MT2 (pdf) Spring 2021 Midterm 2 (pdf) Code handout for Spring 2021 MT2 (pdf) Fall 2020 Midterm 2 (pdf) Code handout for Fall 2020 MT2 (pdf) Note about F20 MT 2: because of the shortened semester Fall 2020, MT 2 came earlier than normal. F20 exam does not cover some of the topics that will be on this semester's MT 2: stacks and queues, binary search (in array and tree), hash tables and hash functions, sorting algorithms. Spring 2020 Midterm 2 (pdf) Fall 2019 Midterm 2 (pdf) Code handout for Fall 2019 MT2 (pdf) Solution for Fall 2019 MT2 Spring 2019 Midterm 2 (pdf) Code handout for Spring 2019 MT2 (pdf) Fall 2018 Midterm 2 (pdf) Spring 2018 Midterm 2 (pdf) Code handout for Spring 2018 MT2 (pdf) Fall 2017 Midterm 2 (pdf) Code handout for Fall 2017 MT2 (pdf) Spring 2017 Midterm 2 (pdf) Solution for Spring 2017 MT2 Fall 2016 Midterm 2 (pdf) Solution for Fall 2016 MT2 Additional sample recursion problems Some problems that are representative of the kinds of and difficulty of recursion problems that might appear on the exam are the Recursion-1 problems on codingbat. Some of these have brief descriptions. On the exam, I would probably give more examples of the input and corresponding output for a problem. Another general hint about these problems: it may help to think about these problems as working from right to left on their input, because they may be doing some work on the way back from the recursive call. For example, one way to solve stringClean is to create the new string from the right to the left, i.e., appending a single character to the front of a string returned from a recursive call. Alternatively, a tail-recursive solution with a helper function could construct the new string from left to right. Codingbat Recursion-1 problems Midterm 1 What's covered: This exam covers everything we have done so far in the course. That includes generally everything in Ch. 1 - 8 of the text (plus only the Special Topics specifically mentioned in the reading assignments), and lecture, video, lab, and programming assignment material not covered in the textbook. However, the following textbook topics will not appear on the exam: 2D arrays packages Unit test frameworks (in Ch. 8) Basic Linux/Unix shell material will also be on the exam. Such questions will be based on material from lab 1 and other tidbits from lecture, labs, and assignments (e.g., wildcards, input redirection). Recall that there is a Linux command summary linked from the Documentation page (you are not responsible for everything in that Summary). Sample midterm 1 exam questions Note: Occasionally there are is a mistake on an exam (or solution) whose correction was announced at the exam; they don't tend to get fixed on these documents later since I don't reuse exams. Some of the following sample exams also have solutions provided. Reviewing an old exam and its solution is not a very effective way to prepare for an upcoming exam. A better way is to take the sample exam under exam-like conditions: closed book, closed note, with a time limit. Once you have completed the exam you can use the posted solution, if available, to check your answers. For those problems whose answers you are unsure of after you have worked the problem, and even after looking up the relevant material, you can go over them with your study group or get help in staff office hours. Fall 2022 Midterm 1 (pdf) Solution for Fall 2022 MT 1 Spring 2022 Midterm 1 (pdf) Fall 2021 Midterm 1 (pdf) Spring 2021 Midterm 1 (pdf) Fall 2020 Midterm 1 (pdf) Spring 2020 Midterm 1 (pdf) Solution for Spring 2020 MT 1 Fall 2019 Midterm 1 (pdf) Spring 2019 Midterm 1 (pdf) Fall 2018 Midterm 1 (pdf) Spring 2018 Midterm 1 (pdf) Fall 2017 Midterm 1 (pdf) Spring 2017 Midterm 1 (pdf) Solution for Spring 2017 MT 1 Fall 2016 Midterm 1 (pdf) Solution for Fall 2016 MT 1