CSE 142, Autumn 2008 Midterm Exam, Friday, October 31, 2008

Similar documents
CSE 142, Summer 2013 Midterm Exam, Friday, July 26, 2013

CSE 142, Autumn 2010 Midterm Exam, Friday, November 5, 2010

CSE 142, Summer 2010 Midterm Exam, Friday, July 30, 2010

CSE 142, Autumn 2011 Midterm Exam: Friday, November 4, 2011

CSE 142, Autumn 2007 Midterm Exam, Friday, November 2, 2007

CSE 142, Autumn 2010 Final Exam Wednesday, December 15, Name:

CSE142 Sample Midterm Spring Name UW NetId (e.g. whitab) Section (e.g., AA) TA

CSE 143, Winter 2010 Midterm Exam Wednesday February 17, 2010

CSE142 Sample Midterm, Winter 2018

CSE 142, Spring 2009, Sample Final Exam #2. Good luck!

CSE 142, Spring 2010 Final Exam Wednesday, June 9, Name: Student ID #: Rules:

CSE142 Sample Midterm Autumn 2018

CSE 143, Winter 2009 Final Exam Thursday, March 19, 2009

CSE 142 Sample Midterm Exam #3

CSE 142, Winter 2007 Final Exam. Name:

CSE 142 Sample Midterm Exam #2

CSE 143, Winter 2010 Final Exam Thursday, March 18, 2010

CSE 143: Computer Programming II Spring 2015 Midterm Exam Solutions

CSE 142, Spring 2009, Final Exam

Building Java Programs A Back to Basics Approach 4th Edition Reges TEST BANK Full download at:

1. An operation in which an overall value is computed incrementally, often using a loop.

CSE 142 Sample Midterm Exam #3

CSE 143: Computer Programming II Spring 2015 Final Exam Solutions

CIS 110 Introduction To Computer Programming. November 21st, 2011 Exam 2

CSE 143: Computer Programming II Autumn Sample Solutions

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

Midterm Review Session

CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam

CSE142 Midterm Autumn This exam is divided into eight questions with the following points: # Problem Area Points Score

CSE 303, Spring 2009 Final Exam Wednesday, June 10, 2009

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

Sample Midterm Exam #2

CIS 110 Introduction to Computer Programming. February 29, 2012 Midterm

CSCI 1226 A Test #1. Wednesday, 10 October, 2018 Name: Student #: General Instructions Read and follow all directions carefully.

CIS 110 Introduction to Computer Programming. 7 May 2012 Final Exam

CSE 154, Autumn 2012 Final Exam, Thursday, December 13, 2012

CSE143 Midterm Summer Name of Student: Section (e.g., AA): Student Number:

Problem Description Earned Max 1 HTML / CSS Tracing 20 2 CSS 20 3 PHP 20 4 JS / Ajax / JSON 20 5 SQL 20 X Extra Credit 1 TOTAL Total Points 100

Final Exam. COMP Summer I June 26, points

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

Problem Description Earned Max 1 CSS 20 2 PHP 20 3 SQL 10 TOTAL Total Points 50

York University AK/ITEC OBJECT-BASED PROGRAMMING. Midterm Test Sample. Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 11, Name: KEY

CIS 110 Introduction To Computer Programming. December 19th, 2011 Final. Answer key

CSCI 1226 Sample Midterm Exam

CSE 373, Winter 2013 Final Exam, Tuesday, March 19, Good luck! You can do it!

JAVA OPERATORS GENERAL

Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 45 Obtained Marks:

NoSuchElementException 5. Name of the Exception that occurs when you try to read past the end of the input data in a file.

CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam

CIS 110 Introduction To Computer Programming. October 5th, 2011 Exam 1. Review problems

CS 312 Midterm 1 Spring 2013

Mid Term Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: Sunday November 3, 2013 Total Marks: 50 Obtained Marks:

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a

COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz

CS 112 Introduction to Programming

McGill University School of Computer Science COMP-202A Introduction to Computing 1

University of Massachusetts Amherst, Electrical and Computer Engineering

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

CSE 1223: Exam II Autumn 2016

1. [3 pts] What is your section number, the period your discussion meets, and the name of your discussion leader?

(c) ((!(a && b)) == (!a!b)) TRUE / FALSE. (f) ((!(a b)) == (!a &&!b)) TRUE / FALSE. (g) (!(!a) && (c-d > 0) && (b!b))

AP COMPUTER SCIENCE A

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 1, Name: KEY A

CIS Introduction to Computer Programming. 5 October 2012 Midterm

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009

Name CIS 201 Midterm II: Chapters 1-8

ENGR 2710U Midterm Exam UOIT SOLUTION SHEET

CSE 114 Midterm 1. Please leave one seat between yourself and each of your neighbors.

Problem Description Earned Max 1 HTML / CSS Tracing 20 2 CSS 20 3 PHP 20 4 JS / Ajax / JSON 20 5 SQL 20 X Extra Credit 1 TOTAL Total Points 100

CIS 110 Introduction To Computer Programming. October 5th, 2011 Exam 1. Answer key for review problems

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 2, Name:

Midterm Examination (MTA)

Computer Sciences 302 Exam 2 Information & Sample Exam

University of Palestine. Mid Exam Total Grade: 100

First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010

Problem Grade Total

CSE 373 Autumn 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

1. Find the output of following java program. class MainClass { public static void main (String arg[])

CSE Fall 2015 Section 002 Exam 2, Time: 80 mins

CIS October 19, 2017

Building Java Programs

Following is the general form of a typical decision making structure found in most of the programming languages:

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring What is your name?: (4 points for writing it on your answer sheet)

Building Java Programs

CS 302: INTRODUCTION TO PROGRAMMING. Lectures 7&8

CSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name

ECOR Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

CSE 1223: Introduction to Computer Programming in Java Chapter 3 Branching

CS 101 Exam 2 Spring Id Name

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 24, Name: KEY 1

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 9, Name: KEY

QUIZ: What value is stored in a after this

McGill University Faculty of Science School of Computer Science. MIDTERM EXAMINATION - Sample solutions. COMP-250: Introduction to Computer Science

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

CIS 110 Introduction To Computer Programming. December 19th, 2011 Final. Answer key for review problems

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 6, Name:

Transcription:

CSE 142, Autumn 2008 Midterm Exam, Friday, October 31, 2008 Name: Section: Student ID #: TA: You have 50 minutes to complete this exam. You may receive a deduction if you keep working after the instructor calls for papers. This exam is open-book/notes. You may not use any computing devices including calculators. Code will be graded on proper behavior/output and not on style, unless otherwise indicated. Do not abbreviate code, such as "ditto" marks or dot-dot-dot... marks. The only abbreviations that are allowed for this exam are: S.o.p for System.out.print, S.o.pln for System.out.println, and S.o.pf for System.out.printf. You do not need to write import statements in your code. If you enter the room, you must turn in an exam before leaving the room. You must show your Student ID to a TA or instructor for your exam to be accepted. Good luck! Score summary: (for grader only) Problem Description Earned Max 1 Expressions 12 2 Parameter Mystery 12 3 If/Else Simulation 12 4 While Loop Simulation 15 5 Assertions 15 6 Programming 20 7 Programming 14 X Extra Credit +1 TOTAL Total Points 100 1 of 8

1. Expressions 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 -(6 + 3-2 * 3) 15 % 6 + 5 % 5 + 12 % 7 % 3 9 / 2 / 2.0 + 9 / 2.0 / 2 5 + 6 + "7" + 8 + 9 + 2 * 3!(3 < 7 && -1!= 8) Value 2. Parameter Mystery At the bottom of the page, write the output produced by the following program, as it would appear on the console. (Though the program uses words related to arithmetic, the output does not necessarily follow the rules of addition.) public class ParameterMystery { public static void main(string[] args) { String i = "j"; int j = -1; int k = 2; String x = "5"; int y = 7; silly(k, i, j); silly(y, x, k); silly(k, "y", 4); silly(j + 1, x + 1, j); public static void silly(int k, String i, int j) { System.out.println(j + " + " + k + " + " + i); 2 of 8

3. If/Else Simulation For each call below to the following method, write the output that is produced, as it would appear on the console: public static void ifelsemystery(int a, int b) { if (a < b) { a = a * 2; if (a > b) { a = a - 10; else { b++; System.out.println(a + " " + b); Method Call ifelsemystery(10, 3); ifelsemystery(6, 6); ifelsemystery(3, 4); ifelsemystery(4, 20); Output 3 of 8

4. While Loop Simulation For each call below to the following method, write the output that is produced, as it would appear on the console: public static void whilemystery(int x, int y, int z) { while (x < z y < z) { x = x + y; y = y * 2; System.out.print(x + " " + y + " "); System.out.println(); Method Call whilemystery(0, 5, 10); whilemystery(4, 2, 12); whilemystery(10, 1, 14); Output 4 of 8

5. Assertions For each of the five points labeled by comments, identify each of the assertions in the table below as either being always true, never true, or sometimes true / sometimes false. public static int randomwalk(int steps) { Random rand = new Random(); int x = 0; int r = rand.nextint(2); // Point A while (steps > 0 x == 0) { // Point B if (r == 0) { x++; // Point C else { x = 0; // Point D steps--; r = rand.nextint(2); // Point E return x; Fill in each box below with one of ALWAYS, NEVER or SOMETIMES. (You may abbreviate them as A, N, or S.) steps > 0 x > 0 r > 0 Point A Point B Point C Point D Point E 5 of 8

6. Programming Write a static method hopscotch that shows a sequence of numbers similar to the appearance of a hopscotch board. (Hopscotch is a "hopping" game played by children.) For this problem, a hopscotch board is an increasing sequence of numbers in lines in an alternating pattern. Odd lines contain a single number indented by 3 spaces. Even lines contain a pair of numbers with the first number not indented, followed by 5 spaces, followed by the second number. Your method should accept a parameter representing the number of "hops" worth of numbers to display. A board of 0 "hops" shows only the number 1, indented by 3 spaces. A "hop" is defined as a trio of additional numbers spread across 2 additional lines, following the pattern described previously. So for example, 1 hop means to show the numbers 2-3-4 to the board in the pattern shown below. 2 hops means to show the numbers 2-3-4, 5-6-7 on the board. 3 hops means to show 2-3-4, 5-6-7, 8-9-10, and so on. Assume that the number of hops passed will be at least 0. Here are some example calls to the method and their resulting console output: Call hopscotch(0); hopscotch(1); hopscotch(2); hopscotch(3); hopscotch(5); Output 1 1 1 2 3 2 3 4 4 5 6 7 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 6 of 8

7. Programming Write a static method named containsbothdigits that accepts three integer parameters a, b, and c. Assume that a is a positive integer (greater than 0) and that b and c are single-digit numbers from 0-9 inclusive. Your method should return true if a contains both b and c at among its digits, and false otherwise. For example, the number 433407 contains 4, 3, 0, and 7 as its unique digit values, so a call to your method of containsbothdigits(433407, 7, 3) should return true. If b and c are the same number, your method should return true if that digit appears at least once among the digits; in other words, the same digit from a could match both b and c. So for example, a call of containsbothdigits(433407, 7, 7) should return true. Note that the digit b or c might appear more than once in a, as with 433407 containing two 3s. The following table lists some additional calls to your method and their expected return values: Call Value Returned Reason containsbothdigits(12345, 2, 5) true 12345 contains the digits 2 and 5 containsbothdigits(3004955, 3, 0) true 3004955 contains the digits 3 and 0 containsbothdigits(1650, 6, 6) true 1650 contains the digit 6 containsbothdigits(12198, 1, 7) false 12198 does not contain the digit 7 containsbothdigits(42, 9, 2) false 42 does not contain the digit 9 containsbothdigits(904487, 2, 6) false 904487 does not contain the digit 2 or 6 containsbothdigits(8, 2, 3) false 8 does not contain the digit 2 or 3 Note: You may not use a String to solve this problem. 7 of 8

X. Extra Credit (+1 point) Describe CSE 142 in two words or less. (Any word you write will get the +1 extra point.) 8 of 8