Faculty of Science COMP-202A - Foundations of Computing (Fall 2013) - All Sections Midterm Examination

Size: px
Start display at page:

Download "Faculty of Science COMP-202A - Foundations of Computing (Fall 2013) - All Sections Midterm Examination"

Transcription

1 First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Foundations of Computing (Fall 2013) - All Sections Midterm Examination November 11th, 2013 Examiners: Jonathan Tremblay [Sections 3 (3:30-4:30) and 2 (1:00-2:30)] 18:00-21:00 Dan Pomerantz [Section 1 (10:30-11:30)] Instructions: DO NOT TURN THIS PAGE UNTIL INSTRUCTED This is a closed book examination; only a letter-sized (8.5 by 11 ) crib sheet is permitted. This crib sheet can be single or double-sided; it can be handwritten or typed. Non-electronic translation dictionaries are permitted, but instructors and invigilators reserve the right to inspect them at any time during the examination. Besides the above, only writing implements (pens, pencils, erasers, pencil sharpeners, etc.) are allowed. The possession of any other tools or devices is prohibited. Answer all questions on the scantron sheet. This examination has 8 pages including this cover page, and is printed on both sides of the paper. On page 7, you will find information about useful classes and methods. You may detach page 7 from the examination if you wish. MAKE SURE TO WRITE YOUR NAME AND STUDENT ID ON THE SCANTRON AS WELL AS TO FILL IN THE BUBBLE PROPERLY AT THE BEGINNING OF THE EXAM

2 COMP-202A - Fall Midterm Examination Page 2 Practice exam The following is designed to give you some practice with answering multiple choice questions. Solutions are listed below. We strongly suggest that you take this exam by writing down all your answers on a separate piece of paper, double checking your work, and only then looking at the solutions to confirm your answers. This is not meant to be a simulation of the real exam in that the exact length may be a bit different. Some notes on your real midterm exam: 1. There are approximately 50 questions total. 2. Of these, approximately 24 are separate questions (worth 2 points each), 14 are linked questions (worth 3 points each) referring to the same piece of code and asking many questions about it, and 10 are true false (worth 1 point each) 3. For the group of questions referring to the same piece of code, it is very important to know your assignments inside and out as the code will share some relation to that. 4. There is no penalty for guessing, so you should guess! 5. All questions within a section are weighted equally, so remember not to waste too much time on one question. 6. You are allowed to bring with you a crib sheet to the exam. The crib sheet can be two sided and typed and you can put whatever you want on it. We recommend putting examples that you found particularly tricky or confusing on it to help you. The point is not to make you memorize random facts that you ll forget afterwards anyway and in fact preparing the crib sheet (and selecting the important bits) can be a key part of studying. 7. Remember that the midterm is designed to be practice for the final. So even though there is an option in the final grading to skip your midterm grade, it is strongly recommended you take the midterm as seriously as possible. 8. There are other old midterms posted. Although there is no programming question on the exam, you can still use the old midterms to practice because the short answer format is similar. The main difference is you now are given choices instead. 9. Good luck!

3 COMP-202A - Fall Midterm Examination Page 3 1. Which of the following is NOT a legal Java statement: (A) int x = 2; (B) double x = 4 + "" + 3; (C) double x = ; (D) String x = "7 / 2"; (E) int x = 3; 2. How many times is the condition of the while loop checked in the following code? int i = 0; while (i < 30) { System.out.println("Repeat!"); i = i + 2; (A) 15 (B) 30 (C) 10 (D) 1 (E) Suppose you have a method with the following header: public static void fun(string x, boolean b) Which of the following are legal ways to call the method: I. fun("3 + 1", true); II. fun(3 + "", false); III. fun("3.0",!true); (A) I only (B) II only (C) III only (D) II and III (E) I, II, and III 4. Which of the following Java expressions do not have a value of true? (A) true (B)!!true (C)!false (D)! (false && true) (E)! (false true)

4 COMP-202A - Fall Midterm Examination Page 4 Type of Errors For each of the following answer whether they would cause an compiler error, runtime error, or a bug. In other cases the mentioned error may not cause a problem for the computer and is merely a question of style. In this case you should choose Style In other cases the question may not cause a problem at all in which case you should answer No Error For example, omitting a statement may lead to any of the above errors depending on where the omission occurred. 5. Omitting comments from your code. 6. Using a variable without declaring it. 7. Accessing an array out of bounds. 8. Storing an int expression into a variable of type double. 9. Incorrect indentation 10. What prints as a result of the following code being run?

5 COMP-202A - Fall Midterm Examination Page 5 public static void main(string[] args) { int x = 1; int y = 3; x = foo(x,y); System.out.println(x + " " + y); public static int foo(int x, int y) { x = x * 2; y = x; return x; (A) 1 3 (B) 2 3 (C) 3 2 (D) 2 3 (E) What value is returned by the following method if the input array is { 2, 3, 4, 1, 2, 1 public static int mystery(int[] array) { int foo = 0; for (int i = 0; i < array.length; i++) { if (i % 2 == 0) { foo = foo - array[i]; else { foo = foo + array[i]; return foo; (A) 3 (B) -3 (C) 5 (D) -5 (E) How many times does the letter A print in the following code? for (int i = 0; i < 6; i++) { for (int j = 2; j <= 5; j+= 2) { System.out.println("A"); (A) 0

6 COMP-202A - Fall Midterm Examination Page 6 (B) 4 (C) 12 (D) 20 (E) How many times does the letter B print in the following code? for (int i = 0; i < 4; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 3; k++) { System.out.println("B"); System.out.println("B"); System.out.println("B"); (A) 8 (B) 18 (C) 24 (D) 30 (E) What String does the following code return if the input to the method is the String with contents ABCD. public static String mystery(string input) { String tricky = ""; for (int i = 0; i < input.length(); i++) { tricky = (char) (input.charat(i) + 3); return tricky; (A) ABCD (B) BCDE (C) CDEF (D) DEFG (E) There is a compiler error because you can t add a char to an int. True false questions In the following questions answer A for true or B for false. 15. In Java, all variables must be declared

7 COMP-202A - Fall Midterm Examination - Appendix Page In Java, all method must be commented. 17. A String can be cast to an int by writing (int) before the String expression. 18. In Java, loops are allowed inside of other loops 19. A method can return more than one value in Java. SUMMARY OF JAVA STANDARD LIBRARY METHODS FOR SELECTED CLASSES String (package java.lang) Methods: public boolean equals(object anobject): Compares this String to anobject. public int length(): Calculates the length of this String. public boolean equalsignorecase(string anotherstring): Compares, ignoring case considerations, this String to anotherstring. public int compareto(string anotherstring): Compares this String to anotherstring lexicographically; returns a negative value if this String occurs before anotherstring, a positive value if this String occurs after anotherstring, and 0 if both Strings are equal. public int comparetoignorecase(string anotherstring): Compares, ignoring case considerations, this String to anotherstring lexicographically; returns a negative value if this String occurs before anotherstring, a positive value if this String occurs after anotherstring, and 0 if both Strings are equal. public String substring(int start, int finish): Returns a new String composed of the this String starting from index start and up to, but not including index of finish public String replace(char c, char d) : Returns a new String with all occurrences of the character c in the this String replaced by the character d. public char[] tochararray(): Converts this String to a new character array. File (package java.io) Methods: public FileSstring pathname): Creates a new File instance that corresponds to the given pathname. Scanner (package java.util) Methods: public Scanner(Inputstream source): Constructs a new Scanner that produces values scanned from the specified input stream. public Scanner(File f): Constructs a new Scanner that produces values scanned from the specified File public double nextdouble(): Scans the next token of the input as a double. public boolean nextboolean(): Scans the next token of the input as a boolean. public int nextint(): Scans the next token of the input as an int. public String nextline(): Advances this Scanner past the current line and returns the input read. public boolean hasnextline(): Checks whether there are further lines left to scan. PrintStream (package java.io) Methods: public void print(boolean b): Prints boolean value b. public void print(double d): Prints double value d. public void print(int i): Prints int value i. public void print(object o): Prints Object o. public void print(string s): Prints String s. public void println(): Terminates the current line by writing the line separator string.

8 COMP-202A - Fall Midterm Examination - Appendix Page 8 public void println(boolean b): Prints boolean value b and then terminates the line. public void println(double d): Prints double value d and then terminates the line. public void println(int i): Prints int value i and then terminates the line. public void println(object o): Prints Object o and then terminates the line. public void println(string s): Prints String s and then terminates the line. Math (package java.lang) Methods: public static double pow(double a, double b): Returns the value of a raised to the power of b. public static double sqrt(double a): Returns the correctly rounded positive square root of double value a. public static double random(): Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. public static double exp(double a): Returns Euler s number e raised to the power of double value a. (base e) of double value a. of double value a.

9 COMP-202A - Fall Midterm Examination - Appendix Page 9 Solutions to above questions 1 B 2 E 3 E 4 E 5 D 6 A 7 B 8 E 9 D 10 B (or D since they are the same!) 11 B 12 C 13 E 14 D 15 A 16 B 17 B 18 A 19 B

Faculty of Science COMP-202A - Foundations of Computing (Fall 2013) - All Sections Midterm Examination

Faculty of Science COMP-202A - Foundations of Computing (Fall 2013) - All Sections Midterm Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Foundations of Computing (Fall 2013) - All Sections Midterm Examination November 11th, 2013 Examiners: Jonathan Tremblay [Sections

More information

Faculty of Science COMP-202A - Foundations of Computing (Fall 2012) - All Sections Midterm Examination

Faculty of Science COMP-202A - Foundations of Computing (Fall 2012) - All Sections Midterm Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Foundations of Computing (Fall 2012) - All Sections Midterm Examination November 7th, 2012 Examiners: Daniel Pomerantz [Sections

More information

Faculty of Science COMP-202A - Foundations of Computing (Fall 2015) - All Sections Midterm Examination

Faculty of Science COMP-202A - Foundations of Computing (Fall 2015) - All Sections Midterm Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Foundations of Computing (Fall 2015) - All Sections Midterm Examination November 5 th, 2015 Examiners: Melanie Lyman-Abramovitch

More information

Faculty of Science COMP-202B - Foundations of Computing (Winter 2016) - All Sections Midterm Examination

Faculty of Science COMP-202B - Foundations of Computing (Winter 2016) - All Sections Midterm Examination Faculty of Science COMP-202B - Foundations of Computing (Winter 2016) - All Sections Midterm Examination February 23 rd, 2016 Examiners: Yang Cai [Section 1 TR (10:00-11:30)] 18:00-21:00 Jackie Chi Kit

More information

Faculty of Science COMP-202B - Introduction to Computing I (Winter 2010) - All Sections Midterm Examination

Faculty of Science COMP-202B - Introduction to Computing I (Winter 2010) - All Sections Midterm Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202B - Introduction to Computing I (Winter 2010) - All Sections Midterm Examination Thursday, March 11, 2010 Examiners: Milena Scaccia

More information

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2011) - All Sections Midterm Examination

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2011) - All Sections Midterm Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Introduction to Computing I (Fall 2011) - All Sections Midterm Examination Monday, October 31, 2011 Examiners: Daniel Pomerantz

More information

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2009) - All Sections Midterm Examination

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2009) - All Sections Midterm Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Introduction to Computing I (Fall 2009) - All Sections Midterm Examination Tuesday, November 3, 2009 Examiners: Mathieu Petitpas

More information

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Final Examination

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Final Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Final Examination Thursday, December 11, 2008 Examiners: Mathieu Petitpas [Section 1] 14:00

More information

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2009) - All Sections Final Examination

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2009) - All Sections Final Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Introduction to Computing I (Fall 2009) - All Sections Final Examination Wednesday, December 16, 2009 Examiners: Mathieu Petitpas

More information

Faculty of Science COMP-202B - Foundations of Computing (Winter 2016) - All Sections Final Examination

Faculty of Science COMP-202B - Foundations of Computing (Winter 2016) - All Sections Final Examination Faculty of Science COMP-202B - Foundations of Computing (Winter 2016) - All Sections Final Examination April 21 st, 2016 Examiners: Yang Cai [Section 1 TR (10:00-11:30)] 14:00-17:00 Jackie Chi Kit Cheung

More information

Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) - All Sections Final Examination

Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) - All Sections Final Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) - All Sections Final Examination Wednesday, April 29, 2009 Examiners: Mathieu Petitpas

More information

Faculty of Science COMP-202A - Foundations of Computing (Fall 2014) - All Sections Final Examination

Faculty of Science COMP-202A - Foundations of Computing (Fall 2014) - All Sections Final Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Foundations of Computing (Fall 2014) - All Sections Final Examination December 9 th, 2014 Examiners: Melanie Lyman-Abramovitch

More information

Faculty of Science COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Final Examination

Faculty of Science COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Final Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Final Examination Wednesday, April 27, 2011 Examiners: Daniel Pomerantz

More information

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2010) - All Sections Final Examination

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2010) - All Sections Final Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Introduction to Computing I (Fall 2010) - All Sections Final Examination Wednesday, December 8, 2010 Examiners: Maja Frydrychowicz

More information

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a Spring 2017 Name: TUID: Page Points Score 1 28 2 18 3 12 4 12 5 15 6 15 Total: 100 Instructions The exam is closed book, closed notes. You may not use a calculator, cell phone, etc. i Some API Reminders

More information

Midterm Exam 2 Thursday, November 15th, points (15% of final grade) Instructors: Jim Williams and Marc Renault

Midterm Exam 2 Thursday, November 15th, points (15% of final grade) Instructors: Jim Williams and Marc Renault Computer Sciences 200 Midterm Exam 2 Thursday, November 15th, 2018 100 points (15% of final grade) Instructors: Jim Williams and Marc Renault (Family) Last Name: (Given) First Name: CS Login Name: NetID

More information

COMP102: Test. 26 April, 2006

COMP102: Test. 26 April, 2006 Name:.................................. ID Number:............................ Signature:.............................. COMP102: Test 26 April, 2006 Instructions Time allowed: 90 minutes (1 1 2 hours).

More information

Computer Science 300 Sample Exam Today s Date 100 points (XX% of final grade) Instructor Name(s) (Family) Last Name: (Given) First Name:

Computer Science 300 Sample Exam Today s Date 100 points (XX% of final grade) Instructor Name(s) (Family) Last Name: (Given) First Name: Computer Science 300 Sample Exam Today s Date 100 points (XX% of final grade) Instructor Name(s) (Family) Last Name: (Given) First Name: CS Login Name: NetID (email): @wisc.edu Circle your Lecture: Lec001

More information

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

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 6, Name: CSC 1051 Algorithms and Data Structures I Midterm Examination October 6, 2016 Name: Question Value Score 1 20 2 20 3 20 4 20 5 20 TOTAL 100 Please answer questions in the spaces provided. If you make a

More information

Computational Expression

Computational Expression Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name

More information

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

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 1, Name: KEY A CSC 1051 Algorithms and Data Structures I Midterm Examination March 1, 2018 Name: KEY A Question Value Score 1 20 2 20 3 20 4 20 5 20 TOTAL 100 Please answer questions in the spaces provided. If you make

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

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

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 11, Name: KEY CSC 1051 Algorithms and Data Structures I Midterm Examination October 11, 2018 Name: KEY Question Value Score 1 20 2 20 3 20 4 20 5 20 TOTAL 100 Please answer questions in the spaces provided. If you make

More information

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

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 2, Name: CSC 1051 Algorithms and Data Structures I Midterm Examination March 2, 2017 Name: Question Value Score 1 10 2 10 3 20 4 20 5 20 6 20 TOTAL 100 Please answer questions in the spaces provided. If you make

More information

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

McGill University School of Computer Science COMP-202A Introduction to Computing 1 McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif

More information

Computer Science 145 Midterm 1 Fall 2016

Computer Science 145 Midterm 1 Fall 2016 Computer Science 145 Midterm 1 Fall 2016 Doodle here. This is a closed-book, no-calculator, no-electronic-devices, individual-effort exam. You may reference one page of handwritten notes. All answers should

More information

SFWR ENG/COMP SCI 2S03 Principles of Programming SOLUTIONS

SFWR ENG/COMP SCI 2S03 Principles of Programming SOLUTIONS SFWR ENG/COMP SCI 2S03 Principles of Programming SOLUTIONS Day Class Midterm Exam Dr. R. Khedri DURATION : 50 minutes McMaster University Midterm Exam (CAS) October 29, 2012 Please CLEARLY print: NAME:

More information

Using APIs. Chapter 3. Outline Fields Overall Layout. Java By Abstraction Chapter 3. Field Summary static double PI

Using APIs. Chapter 3. Outline Fields Overall Layout. Java By Abstraction Chapter 3. Field Summary static double PI Outline Chapter 3 Using APIs 3.1 Anatomy of an API 3.1.1 Overall Layout 3.1.2 Fields 3.1.3 Methods 3.2 A Development Walkthrough 3.2.1 3.2.2 The Mortgage Application 3.2.3 Output Formatting 3.2.4 Relational

More information

Using Java Classes Fall 2018 Margaret Reid-Miller

Using Java Classes Fall 2018 Margaret Reid-Miller Using Java Classes 15-121 Fall 2018 Margaret Reid-Miller Today Strings I/O (using Scanner) Loops, Conditionals, Scope Math Class (random) Fall 2018 15-121 (Reid-Miller) 2 The Math Class The Math class

More information

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

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009 CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009 What is your name?: There are two sections: I. True/False..................... 60 points; ( 30 questions, 2 points each) II.

More information

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

York University AK/ITEC OBJECT-BASED PROGRAMMING. Midterm Test Sample. Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes York University AK/ITEC 1620 3.0 OBJECT-BASED PROGRAMMING Midterm Test Sample Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes This exam is closed textbook(s) and closed notes. Use of any electronic

More information

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

COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz The in-class quiz is intended to give you a taste of the midterm, give you some early feedback about

More information

The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II Instructor: Dr. Bowen Hui. Tuesday, April 19, 2016

The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II Instructor: Dr. Bowen Hui. Tuesday, April 19, 2016 First Name (Print): Last Name (Print): Student Number: The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II 2016 Instructor: Dr. Bowen Hui Tuesday, April 19, 2016 Time: 6:00pm

More information

COMP102: Test 1 Model Solutions

COMP102: Test 1 Model Solutions Family Name:.......................... Other Names:.......................... ID Number:............................ COMP102: Test 1 Model Solutions 27 July, 2007 Instructions Time allowed: 45 minutes.

More information

A variable is a name for a location in memory A variable must be declared

A variable is a name for a location in memory A variable must be declared Variables A variable is a name for a location in memory A variable must be declared, specifying the variable's name and the type of information that will be held in it data type variable name int total;

More information

File I/O Array Basics For-each loop

File I/O Array Basics For-each loop File I/O Array Basics For-each loop 178 Recap Use the Java API to look-up classes/method details: Math, Character, String, StringBuffer, Random, etc. The Random class gives us several ways to generate

More information

CS 211: Existing Classes in the Java Library

CS 211: Existing Classes in the Java Library CS 211: Existing Classes in the Java Library Chris Kauffman Week 3-2 Logisitics Logistics P1 Due tonight: Questions? Late policy? Lab 3 Exercises Thu/Fri Play with Scanner Introduce it today Goals Class

More information

CSC Algorithms and Data Structures I. Midterm Examination February 25, Name:

CSC Algorithms and Data Structures I. Midterm Examination February 25, Name: CSC 1051-001 Algorithms and Data Structures I Midterm Examination February 25, 2016 Name: Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the

More information

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 25, Name: KEY A

CSC 1051 Algorithms and Data Structures I. Midterm Examination February 25, Name: KEY A CSC 1051 Algorithms and Data Structures I Midterm Examination February 25, 2016 Name: KEY A Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in

More information

We now start exploring some key elements of the Java programming language and ways of performing I/O

We now start exploring some key elements of the Java programming language and ways of performing I/O We now start exploring some key elements of the Java programming language and ways of performing I/O This week we focus on: Introduction to objects The String class String concatenation Creating objects

More information

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

CIS 110 Introduction To Computer Programming. November 21st, 2011 Exam 2 CIS 110 Introduction To Computer Programming November 21st, 2011 Exam 2 Name and section # Pennkey (# and username): My signature below certifies that I have complied with the University of Pennsylvania

More information

Programming with Java

Programming with Java Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules

More information

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

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 7, Name: CSC 1051 Algorithms and Data Structures I Midterm Examination October 7, 2013 Name: Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the spaces

More information

Lecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue

Lecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue Lecture 14 CSE11 Fall 2013 For loops, Do While, Break, Continue General Loops in Java Look at other loop constructions Very common while loop: do a loop a fixed number of times (MAX in the example) int

More information

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points)

Part 1 (80 points) Multiple Choice Questions (20 questions * 4 points per question = 80 points) EECS 183 Fall 2013 Exam 1 Part 1 (80 points) Closed Book Closed Notes Closed Electronic Devices Closed Neighbor Turn off Your Cell Phones We will confiscate all electronic devices that we see including

More information

CSI 1100 / 1500 Fall 2004 Introduction to Computer Science I Final Examination

CSI 1100 / 1500 Fall 2004 Introduction to Computer Science I Final Examination CSI 1100 / 1500 Final Examination Page 1 of 13 CSI 1100 / 1500 Fall 2004 Introduction to Computer Science I Final Examination Duration : 3 hours 09:30 December 9, 2004 Professors: Alan Williams, Daniel

More information

CMPS 12A - Winter 2002 Midterm 2 March 5, Name: ID:

CMPS 12A - Winter 2002 Midterm 2 March 5, Name: ID: CMPS 12A - Winter 2002 Midterm 2 March 5, 2002 Name: ID: This is a closed note, closed book exam. Any place where you are asked to write code, you must declare all variables that you use. However, I just

More information

A Quick and Dirty Overview of Java and. Java Programming

A Quick and Dirty Overview of Java and. Java Programming Department of Computer Science New Mexico State University. CS 272 A Quick and Dirty Overview of Java and.......... Java Programming . Introduction Objectives In this document we will provide a very brief

More information

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2010

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2010 CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2010 What is your name?: There are two sections: I. True/False..................... 60 points; ( 30 questions, 2 points each) II.

More information

I. True/False: (2 points each)

I. True/False: (2 points each) CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2004 What is your name?: (0 points) There are two sections: I. True/False..............52 points; ( 26 questions, 2 points each) II.

More information

CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam

CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam Page 0 German University in Cairo April 6, 2017 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam Bar Code

More information

Name CIS 201 Midterm II: Chapters 1-8

Name CIS 201 Midterm II: Chapters 1-8 Name CIS 201 Midterm II: Chapters 1-8 December 15, 2010 Directions: This is a closed book, closed notes midterm. Place your answers in the space provided. The point value for each question is indicated.

More information

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

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 9, Name: KEY CSC 1051 Algorithms and Data Structures I Midterm Examination October 9, 2014 Name: KEY Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the

More information

b. Suppose you enter input from the console, when you run the program. What is the output?

b. Suppose you enter input from the console, when you run the program. What is the output? Part I. Show the printout of the following code: (write the printout next to each println statement if the println statement is executed in the program). a. Show the output of the following code: public

More information

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

CSE 114 Midterm 1. Please leave one seat between yourself and each of your neighbors. CSE 114 Midterm 1 Please leave one seat between yourself and each of your neighbors. Please place ALL of your final answers on the answer sheet that you were given at the start of the exam. Answers and

More information

COMP102: Test 2 Model Solutions

COMP102: Test 2 Model Solutions Family Name:.......................... Other Names:.......................... ID Number:............................ Instructions Time allowed: 90 minutes (1 1 2 hours). There are 90 marks in total. Answer

More information

ing execution. That way, new results can be computed each time the Class The Scanner

ing execution. That way, new results can be computed each time the Class The Scanner ing execution. That way, new results can be computed each time the run, depending on the data that is entered. The Scanner Class The Scanner class, which is part of the standard Java class provides convenient

More information

Final Exam Practice. Partial credit will be awarded.

Final Exam Practice. Partial credit will be awarded. Please note that this problem set is intended for practice, and does not fully represent the entire scope covered in the final exam, neither the range of the types of problems that may be included in the

More information

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

CSE 142, Spring 2009, Sample Final Exam #2. Good luck! CSE 142, Spring 2009, Sample Final Exam #2 Name: Section: Student ID #: TA: Rules: You have 110 minutes to complete this exam. You will receive a deduction if you keep working after the instructor calls

More information

CIS 110 Introduction to Computer Programming Summer 2018 Final. Recitation # (e.g., 201):

CIS 110 Introduction to Computer Programming Summer 2018 Final. Recitation # (e.g., 201): CIS 110 Introduction to Computer Programming Summer 2018 Final Name: Recitation # (e.g., 201): Pennkey (e.g., paulmcb): My signature below certifies that I have complied with the University of Pennsylvania

More information

Classes and Objects Part 1

Classes and Objects Part 1 COMP-202 Classes and Objects Part 1 Lecture Outline Object Identity, State, Behaviour Class Libraries Import Statement, Packages Object Interface and Implementation Object Life Cycle Creation, Destruction

More information

Computer Programming, I. Laboratory Manual. Final Exam Solution

Computer Programming, I. Laboratory Manual. Final Exam Solution Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Final Exam Solution

More information

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

1. An operation in which an overall value is computed incrementally, often using a loop. Practice Exam 2 Part I: Vocabulary (10 points) Write the terms defined by the statements below. 1. An operation in which an overall value is computed incrementally, often using a loop. 2. The < (less than)

More information

Text User Interfaces. Keyboard IO plus

Text User Interfaces. Keyboard IO plus Text User Interfaces Keyboard IO plus User Interface and Model Model: objects that solve problem at hand. User interface: interacts with user getting input from user giving output to user reporting on

More information

Midterm Exam CS 251, Intermediate Programming March 12, 2014

Midterm Exam CS 251, Intermediate Programming March 12, 2014 Midterm Exam CS 251, Intermediate Programming March 12, 2014 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

1. Which of the following is the correct expression of character 4? a. 4 b. 4 c. '\0004' d. '4' Practice questions: 1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4' 2. Will System.out.println((char)4) display 4? a. Yes b. No 3. The expression "Java

More information

Place your name tag here

Place your name tag here CS 170 Exam 1 Section 001 Spring 2015 Name: Place your name tag here Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with

More information

CIS 110 Introduction to Computer Programming Fall 2017 Midterm. Recitation ROOM :

CIS 110 Introduction to Computer Programming Fall 2017 Midterm. Recitation ROOM : CIS 110 Introduction to Computer Programming Fall 2017 Midterm Name: Recitation ROOM : Pennkey (e.g., paulmcb): DO NOT WRITE YOUR ID# ABOVE, YOU WILL LOSE A POINT My signature below certifies that I have

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #04: Fall 2015 1/20 Office hours Monday, Wednesday: 10:15 am to 12:00 noon Tuesday, Thursday: 2:00 to 3:45 pm Office: Lindley Hall, Room 401C 2/20 Printing

More information

CS 302: INTRODUCTION TO PROGRAMMING. Lectures 7&8

CS 302: INTRODUCTION TO PROGRAMMING. Lectures 7&8 CS 302: INTRODUCTION TO PROGRAMMING Lectures 7&8 Hopefully the Programming Assignment #1 released by tomorrow REVIEW The switch statement is an alternative way of writing what? How do you end a case in

More information

CIS 110 Fall 2014 Introduction to Computer Programming 8 Oct 2014 Midterm Exam Name:

CIS 110 Fall 2014 Introduction to Computer Programming 8 Oct 2014 Midterm Exam Name: CIS 110 Fall 2014 Introduction to Computer Programming 8 Oct 2014 Midterm Exam Name: Recitation # (e.g., 201): Pennkey (e.g., eeaton): My signature below certifies that I have complied with the University

More information

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

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm CIS 110 Introduction To Computer Programming February 29, 2012 Midterm Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University of Pennsylvania

More information

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

CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam Seat Number Name CS 1063 Introduction to Computer Programming Midterm Exam 2 Section 1 Sample Exam This is a closed book exam. Answer all of the questions on the question paper in the space provided. If

More information

COMP200 INPUT/OUTPUT. OOP using Java, based on slides by Shayan Javed

COMP200 INPUT/OUTPUT. OOP using Java, based on slides by Shayan Javed 1 1 COMP200 INPUT/OUTPUT OOP using Java, based on slides by Shayan Javed Input/Output (IO) 2 3 I/O So far we have looked at modeling classes 4 I/O So far we have looked at modeling classes Not much in

More information

Section 2: Introduction to Java. Historical note

Section 2: Introduction to Java. Historical note The only way to learn a new programming language is by writing programs in it. - B. Kernighan & D. Ritchie Section 2: Introduction to Java Objectives: Data Types Characters and Strings Operators and Precedence

More information

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

CIS 110 Introduction to Computer Programming. February 29, 2012 Midterm CIS 110 Introduction to Computer Programming February 29, 2012 Midterm Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University of Pennsylvania

More information

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Review Chapters 1 to 4 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Introduction to Java Chapters 1 and 2 The Java Language Section 1.1 Data & Expressions Sections 2.1 2.5 Instructor:

More information

CSE 1223: Exam II Autumn 2016

CSE 1223: Exam II Autumn 2016 CSE 1223: Exam II Autumn 2016 Name: Instructions: Do not open the exam before you are told to begin. This exam is closed book, closed notes. You may not use any calculators or any other kind of computing

More information

Midterm 1 Written Exam

Midterm 1 Written Exam COS 126 Intro to CS Fall 2015 Midterm 1 Written Exam There are eight questions on this exam, weighted as indicated at the bottom of this page. There is one question per lecture, numbered corresponding

More information

Sample Examination Paper Programming and Software Development

Sample Examination Paper Programming and Software Development THE UNIVERSITY OF MELBOURNE DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING Sample Examination Paper 2008 433-520 Programming and Software Development Exam Duration: 2 hours Total marks for this

More information

CIS 110 Fall 2016 Introduction to Computer Programming 13 Oct 2016 Midterm Exam

CIS 110 Fall 2016 Introduction to Computer Programming 13 Oct 2016 Midterm Exam Name: CIS 110 Fall 2016 Introduction to Computer Programming 13 Oct 2016 Midterm Exam Recitation # (e.g., 201): Pennkey (e.g., eeaton): My signature below certifies that I have complied with the University

More information

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution Ch 5 Arrays Multiple Choice Test 01. An array is a ** (A) data structure with one, or more, elements of the same type. (B) data structure with LIFO access. (C) data structure, which allows transfer between

More information

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods COMP-202 Unit 2: Java Basics CONTENTS: Using Expressions and Variables Types Strings Methods Assignment 1 Assignment 1 posted on WebCt and course website. It is due May 18th st at 23:30 Worth 6% Part programming,

More information

Appendix 3. Description: Syntax: Parameters: Return Value: Example: Java - String charat() Method

Appendix 3. Description: Syntax: Parameters: Return Value: Example: Java - String charat() Method Appendix 3 Java - String charat() Method This method returns the character located at the String's specified index. The string indexes start from zero. public char charat(int index) index -- Index of the

More information

CS Final Exam Review Suggestions - Fall 2017

CS Final Exam Review Suggestions - Fall 2017 CS 111 - Final Exam Review Suggestions p. 1 CS 111 - Final Exam Review Suggestions - Fall 2017 last modified: 2016-12-09 You are responsible for material covered in class sessions, lab exercises, and homeworks;

More information

CS 101 Spring 2007 Midterm 2 Name: ID:

CS 101 Spring 2007 Midterm 2 Name:  ID: You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure

More information

CIS 110 Introduction to Computer Programming. 13 February 2013 Make-Up Midterm Midterm

CIS 110 Introduction to Computer Programming. 13 February 2013 Make-Up Midterm Midterm CIS 110 Introduction to Computer Programming 13 February 2013 Make-Up Midterm Midterm Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University

More information

Computer Center. Texas Tech University. Quick Reference Guide For Testing

Computer Center. Texas Tech University. Quick Reference Guide For Testing Computer Center Texas Tech University Quick Reference Guide For Testing Office Hours Monday - Friday, 8 am to 5 pm (Closed Noon-1 pm) (Scanning Hours: 8-11:45; and 1-4:45) Computer Center, 8 th & Boston,

More information

AP Computer Science Java Mr. Clausen Program 6A, 6B

AP Computer Science Java Mr. Clausen Program 6A, 6B AP Computer Science Java Mr. Clausen Program 6A, 6B Program 6A LastNameFirstNameP6A (Quadratic Formula: 50 points) (Including complex or irrational roots) Write a program that begins by explaining the

More information

CS 102 / CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2010

CS 102 / CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2010 CS 102 / CS 107 - Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2010 What is your name?: There are two sections: I. True/False..................... 60 points; ( 30 questions, 2 points each)

More information

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming Exam 1 Prep Dr. Demetrios Glinos University of Central Florida COP3330 Object Oriented Programming Progress Exam 1 is a Timed Webcourses Quiz You can find it from the "Assignments" link on Webcourses choose

More information

COS 126 Midterm 1 Written Exam, Fall 2009

COS 126 Midterm 1 Written Exam, Fall 2009 NAME: login ID: precept: COS 126 Midterm 1 Written Exam, Fall 2009 This test has 8 questions, weighted as indicated. The exam is closed book, except that you are allowed to use a one page cheatsheet. No

More information

CS Final Exam Review Suggestions - Spring 2014

CS Final Exam Review Suggestions - Spring 2014 CS 111 - Final Exam Review Suggestions p. 1 CS 111 - Final Exam Review Suggestions - Spring 2014 last modified: 2014-05-09 before lab You are responsible for material covered in class sessions, lab exercises,

More information

CSE 142, Spring 2009, Final Exam

CSE 142, Spring 2009, Final Exam CSE 142, Spring 2009, Final Exam Name: Section: Student ID #: TA: Rules: You have 110 minutes to complete this exam. You will receive a deduction if you keep working after the instructor calls for papers.

More information

COMP 202 Java in one week

COMP 202 Java in one week CONTENTS: Basics of Programming Variables and Assignment Data Types: int, float, (string) Example: Implementing a calculator COMP 202 Java in one week The Java Programming Language A programming language

More information

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

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2009 CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Spring 2009 What is your name?: There are two sections: I. True/False..................... 72 points; ( 36 questions, 2 points each) II.

More information

CSCI 2101 Java Style Guide

CSCI 2101 Java Style Guide CSCI 2101 Java Style Guide Fall 2017 This document describes the required style guidelines for writing Java code in CSCI 2101. Guidelines are provided for four areas of style: identifiers, indentation,

More information

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class. Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone

More information

COMP 202. Built in Libraries and objects. CONTENTS: Introduction to objects Introduction to some basic Java libraries string

COMP 202. Built in Libraries and objects. CONTENTS: Introduction to objects Introduction to some basic Java libraries string COMP 202 Built in Libraries and objects CONTENTS: Introduction to objects Introduction to some basic Java libraries string COMP 202 Objects and Built in Libraries 1 Classes and Objects An object is an

More information

CIS 130 Exam #2 Review Suggestions

CIS 130 Exam #2 Review Suggestions CIS 130 - Exam #2 Review Suggestions p. 1 * last modified: 11-11-05, 12:32 am CIS 130 Exam #2 Review Suggestions * remember: YOU ARE RESPONSIBLE for course reading, lectures/labs, and especially anything

More information