SPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each

Size: px
Start display at page:

Download "SPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each"

Transcription

1 Your Name: Your Pitt (mail NOT peoplesoft) ID: Part Question/s Points available Rubric Your Score A pt each B pt each C pt each D or 2 pts each E or 2 pts each F or 2 pts each G pt each H pt each I pt each Total out of 50 Do Not Open Until the Exam Begins! Note There are NO syntax errors in this exam! Unless the question specifically states that the code might not comple, if you see one, it DOES NOT EXIST!!! A modified String API is on the last page of the exam. the mgmt Page 1

2 Part A From Exam 1 - worth 6% (1 pt each) Given these variables and corresponding initializations: Variable Declarations int in1, in2; double db1, db2; char ch1, ch2; Variable Initializations in1 = 1; in2 = 2; db1 = 1.1; db2 = 2.2; boolean b1, b2; String s1, s2; ch1 = 'a'; ch2 = 'b'; b1 = true; b2 = false; s1 = "hello"; s2 = "world"; What do these printlns display on the screen? Mark an X if they do not compile System.out.println( in1 / in2 ); System.out.println( in1 % in2 ); System.out.println( in1 * db1 ); System.out.println( ch1!= ch2 ); System.out.println( b1 b2 ); System.out.println ( s1 + " " + (in1 + in2) ); Page 2

3 Part B Types of Data - worth 6% (1 pt each) Mark [T] in the blank for any statements that are true. Leave false statements blank 7 [ ] Primitive types of variables include int, double, char, Boolean, and String. 8 [ ] A primitive type of variable can have only one name and one value. 9 [ ] A reference type of variable such as an object of the Card class and the Deck class that you wrote for Program 09 can have multiple references and can store multiple values of different types. 10 [ ] A primitive type variabls can be accessed, used, and changed only by code that is within the braces where the primitive variable is declared. 11 [ ] A reference types of variable such as an object of the Card class and the Deck class can be accessed, used, and changed by code that is outside the braces where the variable is declared. 12 [ ] All of the data stored in an array must be the same type of data. Page 3

4 Part C Representing the Structure of Data in Memory - 4 points (1 pt each) In the following questions, a series of drawings similar to those Jim used on the board in class to represent how the data is stored in memory are shown. Mark the drawing that best represents the type of data listed. 13. Mark the sketch that best shows how a primitive variable is represented: int num = 42; 14. Mark the sketch that best shows how a String object is represented: String str = Hi ; Page 4

5 15. Mark the sketch that best shows how a one-dimensional array is represented: int [ ] list = 1, 2, 3 ; 16. Mark the sketch that best shows how a two-dimensional array is represented: int [ ] [ ] mat = 1, 2, 3, 4 ; Page 5

6 Part D String Objects worth 5 points (1 pt each ) point Given this code fragment specifically the underlined code: String s1 = "Hi"; String s2 = new String( "Hi" ); if ( s1 == s2 ) System.out.println( "They are equal." ); else System.out.println( "They are NOT equal." ); Mark T in the blank for any of the statements that are true. Leave the false statements unmarked. This will not compile because the use of the equality operator for Strings is not allowed in Java. This compiles but does not always work properly. Depending on the way the Strings are initialized, it could return true or it could return false. This compiles and always works properly. It is always safe to use points ( 1 error = -1, more than 1 error = -1 ) Given this code fragment: String s3 = "01234"; for( int i = s3.length( ) - 1; i > 0; i-- ) System.out.print( s3.charat( i ) ); System.out.println( ); Write the output for this code in the box below: Page 6

7 19. 2 points ( 1 error = -1, more than 1 error = -2 ) Given this code fragment: String s4 = "Hello"; for( int i = 0; i < s4.length( ); i++ ) System.out.print(s4.charAt(s4.length( ) i)); System.out.println( ); Write the output for this code in the box below: Part E One Dimensional Arrays worth 5 points point Given this method definition: static public int mysterymethod1( int [ ] numbers, int key ) for ( int i = 0; i < numbers.length; i++) if ( numbers[ i ] == key ) return i; return -1; What does this method do? (Do NOT write what the code does: It is traversing the array. Rather, write what the method accomplishes when it is finished)? What would be a better name for this method? Page 7

8 21. 1 point Given this main method code: static public void main( String [ ] args ) int [ ] list = 4, 2, 8, 5, 3, 1 ; mysterymethod2( list ); And this method definition: static public void mysterymethod2( int [ ] numbers ) for ( int i = 0; i < numbers.length; i++ ) if ( numbers[ i ] % 2 == 1) System.out.print( numbers[ i ] + " " ); System.out.println( ); Will the method, mysterymethod2 crash when it is executed [ yes ] / [ no ]? If the answer is [ yes ], why? If the answer is [ no ], write the output in the box below: Page 8

9 22. 1 point Given this main method code: static public void main( String [ ] args ) int [ ] list = 4, 2, 8, 5, 3, 1 ; mysterymethod4( list ); And this method definition: static public void mysterymethod4( int [ ] list ) int temp = list[0]; for ( int i = 0; i < list.length - 1; i++ ) list[i] = list[i+1]; list[list.length-1] = temp; Before this method begins execution, the arrangement of the values in the array looks like this: [0] [1] [2] [3] [4] [5] What is the arrangement of values in the array when the method is finished? [0] [1] [2] [3] [4] [5] Page 9

10 23. 2 points ( 1 error = -1, more than 1 error = -2 ) Given this main method code: static public void main( String [ ] args ) int [ ] list = 4, 2, 8, 5, 3, 1 ; mysterymethod3( list ); And this method definition: static public void mysterymethod3( int [ ] list ) for ( int i = 0; i < list.length; i++ ) int hiindex = i; for( int j = i + 1; j < list.length; j++) if ( list[j] > list[hiindex] ) hiindex = j; int temp = list[hiindex]; list[hiindex] = list[i]; list[i] = temp; Before this method begins execution, the arrangement of the values in the array looks like this: [0] [1] [2] [3] [4] [5] The method has two loops. The outer loop uses the loop variable i. The inner loop uses the loop variable j. After the end of the first iteration of the outer loop ( the loop that uses the loop variable, i) what is the arrangement of values in the array? [0] [1] [2] [3] [4] [5] Page 10

11 Part F Two Dimensional Arrays worth 5 points point Given this main method code: static public void main( String [ ] args ) int [ ] [ ] mat = 0, 1, 2, 3, 4, 5 ; System.out.println( mysterymethod1( mat ) ); And this method definition: static public int mysterymethod1( int [ ] [ ] mat ) int number = 0; for ( int row = 0; row < mat.length; row ++) for( int col = 0; col < mat[row].length; col++) number = number + mat[row][col]; return number; What is the output of the println? point Given this main method code: static public void main( String [ ] args ) int [ ] [ ] mat2 = 0, 1, 2, 3, 4, 5, 6, 7, 8 ; System.out.println( mysterymethod2( mat2 ) ); And this method definition: static public int mysterymethod2( int [ ] [ ] mat2 ) int number = 0; for ( int i = 0; i < mat2.length; i++) number = number + mat2[i][i]; return number; What is the output of the println? Page 11

12 Given this main method code: static public void main( String [ ] args ) int [ ] [ ] mat2 = 0, 1, 2, 3, 4, 5, 6, 7, 8 ; int [ ] [ ] mat3 = 0, 1, 2, 3, 3, 3, 0, 1, 2 ; System.out.println( mysterymethod3( mat2 ) ); System.out.println( mysterymethod3( mat3 ) ); And this method definition: static public boolean mysterymethod3( int [ ] [ ] mat2 ) int toprow = 0, bottomrow = mat2.length-1; while( toprow < bottomrow ) int col = 0, right = mat2[0].length; while( col < right ) if ( mat2[toprow][col]!= mat2[bottomrow][col] ) return false; col = col + 1; toprow = toprow + 1; bottomrow = bottomrow - 1; return true; 26. (1 point) What does this method do? (Do NOTwrite what the code does: It is traversing the array. or It returns true. Rather, write what the method accomplishes when it is finished)? 27. (2 points) What is the output of the two printlns? Println #1: Println #2: Page 12

13 Part G Properties of Arrays worth 5 points Below is a one dimensional array named list and a variable named count. Use this array for your answers to the questions in this part: list ????????? count point When we work with one dimensional arrays that are not full, we have to have a variable named count to use when we traverse the loop. Why? Mark the true statements in the following list with a T. Leave the false statements unmarked. 1 point each 29 [ ] The array is full when the value of count is equal to list.length. 30 [ ] If there is room in the array, new values go in element list[count]. 31 [ ] The index of the last valid element of the array is list[list.length]. 32 [ ] The following code fragment effectively deletes the last element in the array: count = count 1; Page 13

14 Part H OOP worth 6 points (1 pt each) 33. Below is the definition of the class Coin used in lecture. Circle any and all constructors ( if any are present in the code ): public class Coin private int value; private String name; public int getvalue( ) return value; Coin ( int v, String n ) setvalue( v ); setname( n ); Coin( ) this( 1, "Penny"); private void setvalue ( int newvalue ) if ( newvalue > 0 ) value = newvalue; else value = 0; public String getname( ) return name; public String tostring( ) return "Name: " + name + " --- value: " + value + " cents"; private void setname ( String newname ) if (newname == null) name = "Error"; else name = newname; 34. In the diagram label the default constructor if one exists in the code. Page 14

15 35. Below is the definition of the class Coin used in lecture. Circle any and all accessors ( if any are present in the code ): public class Coin private int value; private String name; public int getvalue( ) return value; Coin ( int v, String n ) setvalue( v ); setname( n ); Coin( ) this( 1, "Penny"); private void setvalue ( int newvalue ) if ( newvalue > 0 ) value = newvalue; else value = 0; public String getname( ) return name; public String tostring( ) return "Name: " + name + " --- value: " + value + " cents"; private void setname ( String newname ) if (newname == null) name = "Error"; else name = newname; 36 In the following code fragment, the first line declares and news a Coin object named c. The second line must print the value of this Coin object. Finish the code: Coin c = new Coin( 10, Dime ); System.out.println( ); Page 15

16 The following code fragment declares and initializes an array of Coin object that can contain ten coins with different values and different names. Coin[ ] coincolletion = new Coin [ 10 ]; int count = 0; count = readfile( coincollection, args[ 0 ] ); 37. Write the code needed to print the value and name of the last Coin in the array, coincollection : 38. Write the code needed to print the name of the first Coin in the array, coincollection : Page 16

17 Part I Scope (ownership) of Variables worth 8 points (1 point each) public class PartI1 static public void main( String [ ] args ) int number = 42; System.out.println( number ); // print #1 testmethod( number ); System.out.println( number ); // print #4 static void testmethod( int number ) System.out.println( number ); // print #2 number = 0; System.out.println( number ); // print #3 What is the output for each of the numbered printlns? 39. Print #1: 40. Print #2: 41. Print #3: 42. Print #4: Page 17

18 public class PartI2 static public void main( String [ ] args ) int [ ] numberlist = 42 ; System.out.println( numberlist[ 0 ] ); // print #1 testmethod( numberlist ); System.out.println( numberlist[ 0 ] );; // print #4 static void testmethod( int [ ] numberlist ) System.out.println( numberlist[ 0 ] ); // print #2 numberlist[ 0 ] = 0; System.out.println( numberlist[ 0 ] ); // print #3 What is the output for each of the numbered printlns? 43. Print #1: 44. Print #2: 45. Print #3: 46. Print #4: =============================================== This is a modified partial String API for your use on the exam. char charat(int index) Returns the char value at the specified index. boolean equals(string str) Compares this string to the argument int length() Returns the length of this string. Page 18

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A

More information

Selected Questions from by Nageshwara Rao

Selected Questions from  by Nageshwara Rao Selected Questions from http://way2java.com by Nageshwara Rao Swaminathan J Amrita University swaminathanj@am.amrita.edu November 24, 2016 Swaminathan J (Amrita University) way2java.com (Nageshwara Rao)

More information

CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013

CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013 CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013 Name: This exam consists of 6 problems on the following 6 pages. You may use your two-sided hand-written 8 ½ x 11 note sheet during the exam.

More information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8 Today... Java basics S. Bowers 1 of 8 Java main method (cont.) In Java, main looks like this: public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World!"); Q: How

More information

CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013

CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013 CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013 Name: This exam consists of 6 problems on the following 6 pages. You may use your two-sided hand-written 8 ½ x 11 note sheet during the exam.

More information

Lecture 13: Two- Dimensional Arrays

Lecture 13: Two- Dimensional Arrays Lecture 13: Two- Dimensional Arrays Building Java Programs: A Back to Basics Approach by Stuart Reges and Marty Stepp Copyright (c) Pearson 2013. All rights reserved. Nested Loops Nested loops nested loop:

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

Computer Science is...

Computer Science is... Computer Science is... Machine Learning Machine learning is the study of computer algorithms that improve automatically through experience. Example: develop adaptive strategies for the control of epileptic

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 01. An array is a (A) (B) (C) (D) data structure with one, or more, elements of the same type. data structure with LIFO access. data structure, which allows transfer between

More information

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

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003 1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to

More information

Final Exam. COMP Summer I June 26, points

Final Exam. COMP Summer I June 26, points Final Exam COMP 14-090 Summer I 2000 June 26, 2000 200 points 1. Closed book and closed notes. No outside material allowed. 2. Write all answers on the test itself. Do not write any answers in a blue book

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

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

First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010 First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010 NAME (Printed) NAME (Signed) E-mail Exam Rules Show all your work. Your grade will be

More information

Chapter 6 Single-dimensional Arrays

Chapter 6 Single-dimensional Arrays Chapter 6 Single-dimensional s 1. See the section "Declaring and Creating s." 2. You access an array using its index. 3. No memory is allocated when an array is declared. The memory is allocated when creating

More information

CS 307 Midterm 2 Fall 2009

CS 307 Midterm 2 Fall 2009 Points off 1 2 3 4 5 Total off Net Score Exam Number: CS 307 Midterm 2 Fall 2009 Name UTEID login name TA's Name: Oswaldo Rashid Swati (Circle One) Instructions: 1. Please turn off your cell phones and

More information

if (x == 0); System.out.println( x=0 ); if (x = 0) System.out.println( x=0 );

if (x == 0); System.out.println( x=0 ); if (x = 0) System.out.println( x=0 ); Sample Final Exam 1. Evaluate each of the following expressions and show the result and data type of each: Expression Value Data Type 14 % 5 1 / 2 + 1 / 3 + 1 / 4 4.0 / 2.0 Math.pow(2.0, 3.0) (double)(2

More information

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

ANSWER KEY First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010 ANSWER KEY First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010 1. True or False: (a) T An algorithm is a a set of directions for solving

More information

CS 307 Midterm 2 Spring 2008

CS 307 Midterm 2 Spring 2008 Points off 1 2 3 4 Total off Net Score Exam Number: CS 307 Midterm 2 Spring 2008 Name UTEID login name TA's Name: Mario Ruchica Vishvas (Circle One) Instructions: 1. Please turn off your cell phones and

More information

Recitation 02/02/07 Defining Classes and Methods. Chapter 4

Recitation 02/02/07 Defining Classes and Methods. Chapter 4 Recitation 02/02/07 Defining Classes and Methods 1 Miscellany Project 2 due last night Exam 1 (Ch 1-4) Thursday, Feb. 8, 8:30-9:30pm PHYS 112 Sample Exam posted Project 3 due Feb. 15 10:00pm check newsgroup!

More information

CS 102/107 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2011

CS 102/107 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2011 CS 102/107 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2011 What is your name?: This test has the following sections: I. True/False... 60 points; (30 questions, 2 points each) II.

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #07: September 21, 2015 1/30 We explained last time that an array is an ordered list of values. Each value is stored at a specific, numbered position in

More information

CS 307 Midterm 2 Fall 2010

CS 307 Midterm 2 Fall 2010 Points off 1 2 3 4 Total off Net Score Exam Number: CS 307 Midterm 2 Fall 2010 Name UTEID login name TA's Name: Harsh Yi-Chao (Circle One) Instructions: 1. Please turn off your cell phones and other electronic

More information

APCS Semester #1 Final Exam Practice Problems

APCS Semester #1 Final Exam Practice Problems Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester

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

J.43 The length field of an array object makes the length of the array available. J.44 ARRAYS

J.43 The length field of an array object makes the length of the array available. J.44 ARRAYS ARRAYS A Java array is an Object that holds an ordered collection of elements. Components of an array can be primitive types or may reference objects, including other arrays. Arrays can be declared, allocated,

More information

CSCI 135 Midterm Fundamentals of Computer Science I Fall 2011

CSCI 135 Midterm Fundamentals of Computer Science I Fall 2011 CSCI 135 Midterm Fundamentals of Computer Science I Fall 2011 Name: This exam consists of 12 problems on the following 11 pages. You may use your single- side hand- written 8 ½ x 11 note sheet during the

More information

Table of Contents Date(s) Title/Topic Page #s. Chapter 4: Writing Classes 4.1 Objects Revisited

Table of Contents Date(s) Title/Topic Page #s. Chapter 4: Writing Classes 4.1 Objects Revisited Table of Contents Date(s) Title/Topic Page #s 11/6 Chapter 3 Reflection/Corrections 56 Chapter 4: Writing Classes 4.1 Objects Revisited 57 58-59 look over your Ch 3 Tests and write down comments/ reflections/corrections

More information

3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal

3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal APCS A Midterm Review You will have a copy of the one page Java Quick Reference sheet. This is the same reference that will be available to you when you take the AP Computer Science exam. 1. n bits can

More information

1. Expressions - 1 point each. -1 for missing or extra " OR.0. differences in capitalization of true and false okay. No limit on points off.

1. Expressions - 1 point each. -1 for missing or extra  OR.0. differences in capitalization of true and false okay. No limit on points off. CS312 Fall 2017 Final Solution and Grading Criteria. Grading acronyms: AIOBE - Array Index out of Bounds Exception may occur BOD - Benefit of the Doubt. Not certain code works, but, can't prove otherwise

More information

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within

More information

CS 113 MIDTERM EXAM 2 SPRING 2013

CS 113 MIDTERM EXAM 2 SPRING 2013 CS 113 MIDTERM EXAM 2 SPRING 2013 There are 18 questions on this test. The value of each question is: 1-15 multiple choice (3 pts) 17 coding problem (15 pts) 16, 18 coding problems (20 pts) You may get

More information

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

Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination Monday, March 9, 2009 Examiners: Mathieu Petitpas [Section 1] 18:30

More information

CSC 1051 Data Structures and Algorithms I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University

CSC 1051 Data Structures and Algorithms I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Last Class CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides in this

More information

Practice Midterm 1. Problem Points Score TOTAL 50

Practice Midterm 1. Problem Points Score TOTAL 50 CS 120 Software Design I Spring 2019 Practice Midterm 1 University of Wisconsin - La Crosse February 25 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages including the

More information

More non-primitive types Lesson 06

More non-primitive types Lesson 06 CSC110 2.0 Object Oriented Programming Ms. Gnanakanthi Makalanda Dept. of Computer Science University of Sri Jayewardenepura More non-primitive types Lesson 06 1 2 Outline 1. Two-dimensional arrays 2.

More information

Notes from the Boards Set BN19 Page

Notes from the Boards Set BN19 Page 1 The Class, String There are five programs in the class code folder Set17. The first one, String1 is discussed below. The folder StringInput shows simple string input from the keyboard. Processing is

More information

CS 159 Midterm #1 Review Questions

CS 159 Midterm #1 Review Questions 1. Given the following declarations: boolean checked ; double price ; double [] weights ; String [] eids ; CS 159 Midterm #1 Review Questions indicate whether each of the following is a value type or a

More information

Primitive Data, Variables, and Expressions; Simple Conditional Execution

Primitive Data, Variables, and Expressions; Simple Conditional Execution Unit 2, Part 1 Primitive Data, Variables, and Expressions; Simple Conditional Execution Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Overview of the Programming Process Analysis/Specification

More information

I. True/False: (2 points each)

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

More information

CS1083 Week 2: Arrays, ArrayList

CS1083 Week 2: Arrays, ArrayList CS1083 Week 2: Arrays, ArrayList mostly review David Bremner 2018-01-08 Arrays (1D) Declaring and using 2D Arrays 2D Array Example ArrayList and Generics Multiple references to an array d o u b l e prices

More information

Final Exam CS 152, Computer Programming Fundamentals December 9, 2016

Final Exam CS 152, Computer Programming Fundamentals December 9, 2016 Final Exam CS 152, Computer Programming Fundamentals December 9, 2016 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

CS 307 Midterm 1 Fall 2007

CS 307 Midterm 1 Fall 2007 Points off 1 2 3 4 Total off Net Score CS 307 Midterm 1 Fall 2007 Your Name Your UTEID Circle yours TA s name: David Joseph Ola Instructions: 1. Please turn off your cell phones 2. There are 4 questions

More information

University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ Test 2. Question Max Mark Internal External

University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ Test 2. Question Max Mark Internal External Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2009 Test 2 Question Max Mark Internal

More information

Chief Reader Report on Student Responses:

Chief Reader Report on Student Responses: Chief Reader Report on Student Responses: 2017 AP Computer Science A Free-Response Questions Number of Students Scored 60,519 Number of Readers 308 Score Distribution Exam Score N %At Global Mean 3.15

More information

Last Name: Circle One: OCW Non-OCW

Last Name: Circle One: OCW Non-OCW First Name: AITI 2004: Exam 1 June 30, 2004 Last Name: Circle One: OCW Non-OCW Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot

More information

CS 139 Practice Midterm Questions #2

CS 139 Practice Midterm Questions #2 CS 139 Practice Midterm Questions #2 Spring 2016 Name: 1. Write Java statements to accomplish each of the following. (a) Declares numbers to be an array of int s. (b) Initializes numbers to contain a reference

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

Lesson 9: Introduction To Arrays (Updated for Java 1.5 Modifications by Mr. Dave Clausen)

Lesson 9: Introduction To Arrays (Updated for Java 1.5 Modifications by Mr. Dave Clausen) Lesson 9: Introduction To Arrays (Updated for Java 1.5 Modifications by Mr. Dave Clausen) 1 Lesson 9: Introduction Objectives: To Arrays Write programs that handle collections of similar items. Declare

More information

CSE 11 Midterm Fall 2008

CSE 11 Midterm Fall 2008 Signature cs11f Name Student ID CSE 11 Midterm Fall 2008 Page 1 (10 points) Page 2 (22 points) Page 3 (23 points) Page 4 (17 points) Page 5 (12 points) Total (84 points = 80 base points + 4 points EC [5%])

More information

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018 Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment

More information

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

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below. C212 Early Evaluation Exam Mon Feb 10 2014 Name: Please provide brief (common sense) justifications with your answers below. 1. What is the type (and value) of this expression: 5 * (7 + 4 / 2) 2. What

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

Exam 2. CSC 121 MW Class. Lecturer: Howard Rosenthal. April 26, 2017

Exam 2. CSC 121 MW Class. Lecturer: Howard Rosenthal. April 26, 2017 Your Name: Exam 2. CSC 121 MW Class Lecturer: Howard Rosenthal April 26, 2017 The following questions (or parts of questions) in numbers 1-7 are all worth 3 points each. 1. Answer the following as true

More information

CSC 1051 Arrays - Review questions

CSC 1051 Arrays - Review questions CSC 5 Arrays - Review questions ) Given the following declarations: int a = 2; int b = 3; int c = 5; double x = 2.5; double y =.; double z = 4.32; double[] list = 2., 3.8,.4}; Show what value is assigned

More information

AP Computer Science A Unit 7. Notes on Arrays

AP Computer Science A Unit 7. Notes on Arrays AP Computer Science A Unit 7. Notes on Arrays Arrays. An array is an object that consists of an of similar items. An array has a single name and the items in an array are referred to in terms of their

More information

CS170 Introduction to Computer Science Midterm 2

CS170 Introduction to Computer Science Midterm 2 CS170 Introduction to Computer Science Midterm 2 03/25/2009 Name: Solution You are to honor the Emory Honor Code. This is a closed book and closednotes exam, and you are not to use any other resource than

More information

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

1. [3 pts] What is your section number, the period your discussion meets, and the name of your discussion leader? CIS 3022 Prog for CIS Majors I October 4, 2007 Exam I Print Your Name Your Section # Total Score Your work is to be done individually. The exam is worth 104 points (four points of extra credit are available

More information

Spring 2010 Java Programming

Spring 2010 Java Programming Java Programming: Guided Learning with Early Objects Chapter 7 - Objectives Learn about arrays Explore how to declare and manipulate data in arrays Learn about the instance variable length Understand the

More information

CS 307 Midterm 2 Spring 2011

CS 307 Midterm 2 Spring 2011 Points off 1 2 3 4 5 Total off Net Score Exam Number: CS 307 Midterm 2 Spring 2011 Name UTEID login name TA's Name: Dan Muhibur Oliver (Circle One) Instructions: 1. Please turn off your cell phones and

More information

Computer Science II (20082) Week 1: Review and Inheritance

Computer Science II (20082) Week 1: Review and Inheritance Computer Science II 4003-232-08 (20082) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Syntax and Semantics of Formal (e.g. Programming) Languages Syntax

More information

CS 101 Fall 2006 Midterm 3 Name: ID:

CS 101 Fall 2006 Midterm 3 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

Arrays. Outline 1/7/2011. Arrays. Arrays are objects that help us organize large amounts of information. Chapter 7 focuses on:

Arrays. Outline 1/7/2011. Arrays. Arrays are objects that help us organize large amounts of information. Chapter 7 focuses on: Arrays Arrays Arrays are objects that help us organize large amounts of information Chapter 7 focuses on: array declaration and use bounds checking and capacity arrays that store object references variable

More information

Week 6 CS 302. Jim Williams, PhD

Week 6 CS 302. Jim Williams, PhD Week 6 CS 302 Jim Williams, PhD This Week Lab: Multi-dimensional Arrays Exam 1: Thursday Lecture: Methods Review Midterm Exam 1 What is the location of the exam? 3650 Humanities 125 Ag Hall 272 Bascom

More information

University Interscholastic League. Computer Science Competition

University Interscholastic League. Computer Science Competition University Interscholastic League Computer Science Competition Number 121 (District 1-2010) General Directions (Please read carefully!): 1) DO NOT OPEN EXAM UNTIL TOLD TO DO SO. 2) NO CALCULATOR OF ANY

More information

CS212 Midterm. 1. Read the following code fragments and answer the questions.

CS212 Midterm. 1. Read the following code fragments and answer the questions. CS1 Midterm 1. Read the following code fragments and answer the questions. (a) public void displayabsx(int x) { if (x > 0) { System.out.println(x); return; else { System.out.println(-x); return; System.out.println("Done");

More information

Choose 3 of the 1 st 4 questions (#'s 1 through 4) to complete. Each question is worth 12 points.

Choose 3 of the 1 st 4 questions (#'s 1 through 4) to complete. Each question is worth 12 points. Choose 3 of the 1 st 4 questions (#'s 1 through 4) to complete. Each question is worth 12 points. Use the remaining question as extra credit (worth 1/2 of the points earned). Specify which question is

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

STUDENT LESSON A12 Iterations

STUDENT LESSON A12 Iterations STUDENT LESSON A12 Iterations Java Curriculum for AP Computer Science, Student Lesson A12 1 STUDENT LESSON A12 Iterations INTRODUCTION: Solving problems on a computer very often requires a repetition of

More information

Ticket Machine Project(s)

Ticket Machine Project(s) Ticket Machine Project(s) Understanding the basic contents of classes Produced by: Dr. Siobhán Drohan (based on Chapter 2, Objects First with Java - A Practical Introduction using BlueJ, David J. Barnes,

More information

CS 177 Week 15 Recitation Slides. Review

CS 177 Week 15 Recitation Slides. Review CS 177 Week 15 Recitation Slides Review 1 Announcements Final Exam on Friday Dec. 18 th STEW 183 from 1 3 PM Complete your online review of your classes. Your opinion matters!!! Project 6 due Just kidding

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Lecture 6. Assignments. Summary - Variables. Summary Program Parts 1/29/18. Reading: 3.1, 3.2, 3.3, 3.4

Lecture 6. Assignments. Summary - Variables. Summary Program Parts 1/29/18. Reading: 3.1, 3.2, 3.3, 3.4 Assignments Lecture 6 Complete for Project 1 Reading: 3.1, 3.2, 3.3, 3.4 Summary Program Parts Summary - Variables Class Header (class name matches the file name prefix) Class Body Because this is a program,

More information

Practice Questions for Chapter 9

Practice Questions for Chapter 9 Practice Questions for Chapter 9 MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) An object is an instance of a. 1) A) program B) method C) class

More information

Assignment 1 due Monday at 11:59pm

Assignment 1 due Monday at 11:59pm Assignment 1 due Monday at 11:59pm The heart of Object-Oriented Programming (Now it gets interesting!) Reading for next lecture is Ch. 7 Focus on 7.1, 7.2, and 7.6 Read the rest of Ch. 7 for class after

More information

CS 1331 Exam 1. Fall Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score.

CS 1331 Exam 1. Fall Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score. CS 1331 Exam 1 Fall 2016 Name (print clearly): GT account (gpburdell1, msmith3, etc): Section (e.g., B1): Signature: Failure to properly fill in the information on this page will result in a deduction

More information

CIS 265/506 Exam1 Spring 2012 Prof. V. Matos Exam Last Name First Name:

CIS 265/506 Exam1 Spring 2012 Prof. V. Matos Exam Last Name First Name: CIS 265/506 Exam1 Spring 2012 Prof. V. Matos Exam Last Name First Name: MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Suppose x = 1, y = -1,

More information

FORM 2 (Please put your name and form # on the scantron!!!!)

FORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam 2: FORM 2 (Please put your name and form # on the scantron!!!!) True (A)/False(B) (2 pts each): 1. Recursive algorithms tend to be less efficient than iterative algorithms. 2. A recursive function

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

Final Exam COMP Fall 2004 Dec 16, 2004

Final Exam COMP Fall 2004 Dec 16, 2004 1. Closed book and closed notes. Final Exam COMP 14-062 Fall 2004 Dec 16, 2004 2. Write all scratch work and answers on the exam itself. If you need extra space, let me know. Indicate your final answer

More information

Fundamentals of Programming Data Types & Methods

Fundamentals of Programming Data Types & Methods Fundamentals of Programming Data Types & Methods By Budditha Hettige Overview Summary (Previous Lesson) Java Data types Default values Variables Input data from keyboard Display results Methods Operators

More information

In Java there are three types of data values:

In Java there are three types of data values: In Java there are three types of data values: primitive data values (int, double, boolean, etc.) arrays (actually a special type of object) objects An object might represent a string of characters, a planet,

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and

More information

Class API. Class API. Constructors. CS200: Computer Science I. Module 19 More Objects

Class API. Class API. Constructors. CS200: Computer Science I. Module 19 More Objects CS200: Computer Science I Module 19 More Objects Kevin Sahr, PhD Department of Computer Science Southern Oregon University 1 Class API a class API can contain three different types of methods: 1. constructors

More information

Prelim One Solution. CS211 Fall Name. NetID

Prelim One Solution. CS211 Fall Name. NetID Name NetID Prelim One Solution CS211 Fall 2005 Closed book; closed notes; no calculators. Write your name and netid above. Write your name clearly on each page of this exam. For partial credit, you must

More information

University of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007

University of Cape Town ~ Department of Computer Science. Computer Science 1015F ~ 2007 Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2007 Final Examination Question Max

More information

Administration. Objects and Arrays. Objects. Agenda. What is an Object? What is a Class?

Administration. Objects and Arrays. Objects. Agenda. What is an Object? What is a Class? Administration Objects and Arrays CS 99 Summer 2000 Michael Clarkson Lecture 6 Read clarified grading policies Lab 6 due tomorrow Submit.java files in a folder named Lab6 Lab 7 Posted today Upson Lab closed

More information

CS 1331 Exam 1 ANSWER KEY

CS 1331 Exam 1 ANSWER KEY CS 1331 Exam 1 Fall 2016 ANSWER KEY Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score. Signing signifies you are aware of and in

More information

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 16 Mar 2017 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment

More information

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer Computing Science 114 Solutions to Midterm Examination Tuesday October 19, 2004 INSTRUCTOR: I E LEONARD TIME: 50 MINUTES In Questions 1 20, Circle EXACTLY ONE choice as the best answer 1 [2 pts] What company

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

PIC 10A. Final Review: Part I

PIC 10A. Final Review: Part I PIC 10A Final Review: Part I Final exam The final exam is worth 30% of your grade, same weight as 2 midterms. Could be 50% if grading option 2 turns out better for you. Length is also roughly 2 midterms

More information

Practice Midterm 1 Answer Key

Practice Midterm 1 Answer Key CS 120 Software Design I Fall 2018 Practice Midterm 1 Answer Key University of Wisconsin - La Crosse Due Date: October 5 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages

More information

PIC 10A. Final Review

PIC 10A. Final Review PIC 10A Final Review Final exam Thursday, December 18, 2014 8:00 AM - 11:00 AM MS 5200. In our usual class room. (Verify on my.ucla.edu!!) The final exam is worth 30% of your grade, same weight as 2 midterms.

More information

CS 101 Exam 1 Spring 200 Id Name

CS 101 Exam 1 Spring 200  Id Name This exam is open text book and closed notes. Different questions have different points associated with them with later occurring questions having more worth than the beginning questions. Because your

More information

Section 2.2 Your First Program in Java: Printing a Line of Text

Section 2.2 Your First Program in Java: Printing a Line of Text Chapter 2 Introduction to Java Applications Section 2.2 Your First Program in Java: Printing a Line of Text 2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using a. Two

More information

CS 170 Section 3, Spring 2015 Programming in Java Midterm Exam 1. Name (print):

CS 170 Section 3, Spring 2015 Programming in Java Midterm Exam 1. Name (print): Name (print): INSTRUCTIONS: o Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. o Do NOT communicate with anyone other than the professor/proctor for ANY reason

More information

The Basic Parts of Java

The Basic Parts of Java Data Types Primitive Composite The Basic Parts of Java array (will also be covered in the lecture on Collections) Lexical Rules Expressions and operators Methods Parameter list Argument parsing An example

More information

9 Working with the Java Class Library

9 Working with the Java Class Library 9 Working with the Java Class Library 1 Objectives At the end of the lesson, the student should be able to: Explain object-oriented programming and some of its concepts Differentiate between classes and

More information

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

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination Tuesday, November 4, 2008 Examiners: Mathieu Petitpas [Section 1] 18:30

More information