CS 177 Spring 2009 Final Exam

Size: px
Start display at page:

Download "CS 177 Spring 2009 Final Exam"

Transcription

1 CS 177 Spring 2009 Final Exam There are 60 multiple choice questions. Each one is worth 4 points. The total score for the exam is 240. Answer the multiple choice questions on the bubble sheet given. Fill in the Instructor, Course, Signature, Test, and Date blanks. For Instructor put your RECITATION INSTRUCTOR S LAST NAME GIVEN BELOW. For Course put CS 177. For Test put final. Fill in the bubbles that correspond to your name, section and Student ID in the bubble sheet. For your section number, use the SECTION NUMBER of your recitation section. Consult the following list: 001 FRI 07:30 HAAS G066 Pelin Angin 002 FRI 08:30 HAAS G066 Jackie Soenneker 003 FRI 10:30 HAAS G066 Ryan Phelps 004 FRI 02:30 HAAS G066 Yao Zhu 005 FRI 03:30 HAAS G066 Younsun Cho 006 FRI 12:30 HAAS G066 Tion Thomas 016 FRI 11:30 REC 117 Yi-Liu Chao For your student ID, use the 10 digit ID number on your student ID card. DO NOT USE YOUR SOCIAL SECURITY NUMBER! Exams without names will be graded as zero. Only the answers on the bubble sheet will be counted. The questions will be discarded. Recitation Section Number Recitation TA s Name Student Last Name Student First Name

2 Multiple Choice Questions (4 points each): 1. Which of the following is the equivalent of the StdIn.readInt() method? (a) Getting the first argument in the command line arguments using args[0] (b) StdIn.readString() followed by Integer.parseInt() (c) It is not possible to achieve the task this method does in any other way. (d) StdIn.readString() followed by Double.parseDouble() 2. Which of the following best explains the effect of piping two programs using the operator? (a) Both programs run faster. (b) The output from the first program is fed as input to the second program. (c) The input to the second program is read from the same file providing input to the first program. (d) The output from the second program is written to a file following the output of the first program. 3. How do we represent sound using the StdAudio class in Java? (a) As an array of double values between 0 and 1. (b) As an object of the StdAudio class. (c) As an array of double values between -1 and 1. (d) There is no way to represent sound in Java. 4. Which of the following methods of the StdAudio class is used to play the sound from a file? (a) save(string file, double[] a) (b) play(int[] file) (c) play(string file) (d) play(double file) 5. What does the following program do? public class Sum { public static void main( String[] args ) { int sum = 0; for (int i = 0; i < 10; i++) { int num = StdIn.readInt(); if ( num % 2 == 0 ) { sum += num; System.out.println( sum ); (a) Prints the sum of the ten numbers input by the user. (b) Prints the sum of the odd numbers from ten numbers input by the user. (c) Prints the average of ten numbers input by the user. (d) Prints the sum of the even numbers from ten numbers input by the user. 1

3 6. What is the effect of executing the following command? java Program1 > file.txt (a) Program1 is compiled. (b) The output from the program Program1 is printed to the console. (c) The program Program1 gets its input from the file file.txt. (d) The output from the program Program1 is redirected to the file file.txt. 7. What is the problem with the following program? public class Print { public static void main( String[] args ) { for (int i = 0; i < 10; i++) { int num = StdIn.readDouble(); System.out.println( num ); (a) Assigning the value returned by the StdIn.readDouble() to an int causes a compiler error due to loss of precision. (b) We cannot print a double value using System.out.println(). (c) There is no readdouble() method in the StdIn class. (d) We cannot declare the variable num in the for loop. 8. What does the following program do? public class Test { public static void main( String[] args ) { String file = "amazing.wav"; double samples[] = StdAudio.read(file); for ( int i = 0; i < samples.length; i++ ) { double amount = 2*Math.random() - 1; samples[i] += amount; if ( samples[i] > 1 ) samples[i] = 1; else if( samples[i] < -1 ) samples[i] = -1; StdAudio.play(samples); (a) Plays the sound in the file amazing.wav without changes. (b) Reverses the sound in the file amazing.wav. (c) Adds noise to the sound in the file amazing.wav. (d) Increases the volume of the sound in the file amazing.wav. 2

4 9. What does the following program do? public class Test { public static void main( String[] args ) { String file = "amazing.wav"; double[] sound = StdAudio.read(file); double temp; for( int i = 0; i < sound.length / 2; i++ ) { temp = sound[i]; sound[i] = sound[sound.length i]; sound[sound.length i] = temp; StdAudio.play(sound); (a) Increases the volume of the sound in the file amazing.wav. (b) Plays the sound in the file amazing.wav without changes. (c) Reverses the sound in the file amazing.wav. (d) Adds noise to the sound in the file amazing.wav. 10. What does the following program do? public class Test { public static void main( String[] args ) { String file = "amazing.wav"; double[] sound = StdAudio.read(file); double[] newsound = new double[sound.length/2]; for( int i = 0; i < newsound.length; i++ ) newsound[i] = sound[2*i]; StdAudio.play( newsound ); (a) Doubles the speed of the sound in the file amazing.wav. (b) Adds noise to the sound in the file amazing.wav. (c) Increases the volume of the sound in the file amazing.wav. (d) Lowers the speed of the sound in the file amazing.wav by a factor of two. 11. Which of the following statements is true for large input sizes when one compares the worst case running time of the sequential search algorithm to that of binary search? (a) Binary search is slower than sequential search. (b) Binary search and sequential search are equally fast. (c) Binary search is faster than sequential search. (d) We cannot determine a relationship between binary search and sequential search. 3

5 12. Here are some statements about inputs to the binary search algorithm. Which of these is true? (a) The algorithm only works on sorted lists of elements. (b) The algorithm only works on lists with a small number of elements. (c) The algorithm only works on unsorted lists of elements. (d) The algorithm works on both sorted and unsorted lists of elements. 13. Which of the following options correctly describes the ordering of binary search, sequential search, bubble sort and insertion sort in terms of worst case running time? (a) binary search < sequential search < bubble sort < insertion sort (b) binary search < bubble sort < insertion sort < sequential search (c) bubble sort = insertion sort < binary search < sequential search (d) binary search < sequential search < bubble sort = insertion sort 14. Consider the data types that can be handled by bubble sort, insertion sort, and bucket sort. Which of the following statements is not true? (a) Bucket sort can be used to sort any kind of comparable data. (b) All three sorts can be used to sort integers. (c) Bubble sort can be used to sort any kind of comparable data. (d) Insertion sort can be used to sort any kind of comparable data. 15. What algorithm does the following function implement? private static int algorithm(int[] array, int value){ int left = 0, right = array.length-1; while ( right >= left ){ int middle = (right+left)/2; if ( array[middle] == value ) return middle; else if ( array[middle] > value ) right = middle-1; else // array[middle] < value return -1; left = middle +1; (a) Bubble sort (b) Binary search (c) Sequential search (d) Insertion sort 4

6 16. Which of the following statements about control structures is true? (a) The body of a do-while loop will not necessarily be executed. (b) The body of a for loop will always be executed at least one time. (c) We can always convert a for loop into a while loop and vice versa. (d) Any if-else statement could be converted into a switch statement. 17. Let array be an array of 10 integers. What are its contents after the following loop? for ( int i = 0; i < array.length; i++ ) array[i] = i/2; (a) {0, 0, 1, 1, 2, 2, 3, 3, 4, 4 (b) {0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5 (c) {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (d) {0, 2, 4, 6, 8, 10, 12, 14, 16, Let array be declared as follows: int[] array = {0, 1, 2, 3, 4; What are the contents of array after the following loop? for ( int i = 1; i < array.length; i++ ) array[i] += array[i-1]; Note: Pay attention to when each element is changed. (a) {0, 1, 3, 5, 7 (b) {0, 1, 2, 3, 4 (c) {0, 1, 2, 4, 8 (d) {0, 1, 3, 6, Consider the following code fragment. Let array be an array of type int. What is the relationship between the variable a and array? double a = 0; for ( int i = 0; i < array.length; i++ ) a += array[i]; a /= array.length; (a) a is the average of all elements in array. (b) a is the minimum of all elements in array. (c) a is the maximum of all elements in array. (d) a is the sum of all elements in array. 5

7 20. Given the following Java classes, what is the output when the main() method in the Test class is run? public class Bug { public void crawl() { System.out.println("crawling..."); public void fly() { System.out.println("flying..."); public class Spider extends Bug { public void fly() { System.out.println("can t fly..."); public void spin() { System.out.println("spinning web..."); public class Test { public static void main(string[] args) { Spider spider = new Spider(); spider.fly(); spider.crawl(); Bug bug = spider; bug.fly(); bug = new Bug(); bug.fly(); (a) can t fly... crawling... can t fly... can t fly... (b) can t fly... crawling... flying... flying... (c) can t fly... crawling... can t fly... flying... (d) This code has an error and will not compile. 6

8 21. What does it mean to override a method? (a) To write a method with the same name as another method but with different parameter types. (b) To call a method from an external library instead of from the same class. (c) To write a method in a child class that has the same name as a method in a parent class. (d) To exit a method with a return statement before the method terminates. 22. Why is it a good idea to hide member variables inside an object with the keyword private? (a) To make programming harder. (b) To keep access to member variables restricted to static methods. (c) To keep other objects from corrupting the values of the member variables in unexpected ways. (d) To tease other objects. 23. Which of the following class inheritance choices makes the most sense? (a) Mammal extends Tiger (b) Seed extends Apple (c) StreptococcusBacteria extends Thing (d) Violin extends StringedInstrument 24. What is a difference between static and non-static methods? (a) Static methods return primitive types and non-static methods return objects. (b) Non-static methods belong to a class, whereas static methods belong to objects. (c) Non-static methods can access member variables, but static methods cannot. (d) Static methods return a value and non-static methods have a void return type. 25. Consider the static method increment() below. public static void donothing(int i) { i = i + 2; How many times will the following for loop iterate? for (int i = 0; i < 10; i++) donothing(i); (a) 9 times (b) 3 times (c) 5 times (d) 10 times 7

9 26. What is the error in the following code? public class Person { private String name; public Person() { name = "Jeeves"; public static void printname() { System.out.println("What ho, " + name + "!"); public static void main(string[] args) { printname(); (a) Using the Person class without calling its constructor will cause a run-time error. (b) There is no error in the code. (c) Trying to access a private variable from a static method will cause a compiler error. (d) Trying to access a non-static variable from a static method will cause a compiler error. 27. What would be a valid return statement inside of a method with the following signature? public static double getsample(string sample) (a) return sample; (b) return a ; (c) return; (d) return 5.1; 28. Consider the error below. % java Bad Exception in thread "main" java.lang.arrayindexoutofboundsexception: 0 at Bad.compile(Bad.java:4) at Bad.main(Bad.java:7) This is an example of a (a) syntax error (b) compile-time error (c) null pointer error (d) run-time error 8

10 29. Which of the following is not a valid variable declaration in Java? (a) int 123abc; (b) int abc123; (c) int Abc; (d) int a_b_c; 30. Which of the following is not a true statement regarding Strings in Java? (a) String is an example of a primitive data type in Java. (b) A String contains a list of characters. (c) It is possible to determine the length of a String in Java. (d) The + operator can be used on String objects to concatenate them together. 31. What would the value of var be after the following code is run? boolean a = true; boolean b = false; boolean var =!((a &&!b) a); (a) true (b) Its value depends on user input. (c) false (d) There is a compilation error in the code. 32. Consider the following class file: public class Phone { public final int number = ; public Phone (int value) { number = value; public void DialNumber() { System.out.println("Dialing number: " + number); Which of the following best describes the compilation error that is present in this code? (a) The variable number is not within the scope of the DialNumber() method. (b) The variable number in the DialNumber() method must be of type String to be used in the System.out.println() method. (c) The final member variable number can only be assigned a value in the constructor of the class. (d) The final member variable number cannot be reassigned in the constructor since final variables can only be assigned a value once. 9

11 33. What will be printed to the screen as a result of running the following code: public static void main(string[] args) { String expression = "1" ; double value = Double.parseDouble(expression); double roundedvalue = Math.round(value); int integervalue = (int)value; System.out.println("Output: "); System.out.print("Original Value: " + value + "\nrounded Value: " + roundedvalue + "\ninteger Value: " + integervalue); (a) Output: Original Value: Rounded Value: Integer Value: 121 (b) Output: Original Value: \nRounded Value: 121.0\nInteger Value: 121 (c) Output: Original Value: Rounded Value: Integer Value: 120 (d) Output: Original Value: \nRounded Value: 121.0\nInteger Value: Which of the following statements about constructor methods is not true? (a) The code within a constructor is primarily used to initialize the member variables of an object. (b) You must always define a constructor method for your class or else Java will give a compiler error. (c) Invoking a constructor creates an instance of an object and returns a reference to that object. (d) A constructor is invoked when a program uses the new keyword. 35. What data type could be returned by method check() given that the following fragment of code is valid? if (check().equals("1")) System.out.println("Get sale."); else System.out.println("Go to next store."); (a) String (b) char (c) boolean (d) int 10

12 36. Consider the following class file: public class Money { private double amount; public Money (double initialamount) { amount = initialamount; public double addamount(int dollars, int cents) { String newamount = ""; newamount = newamount + dollars + "." + cents; double convertedamount = Double.parseDouble(newAmount); System.out.println("Converted amount = " + convertedamount); amount += convertedamount; return amount; Which set of the following statements provides the best categorization of the variables used in the Money class? (a) Member variables: amount, initialamount Argument variables: dollars, cents Local Variables: newamount, convertedamount (b) Member variables: newamount, convertedamount Argument variables: initialamount, dollars, cents Local Variables: amount (c) Member variables: amount Argument variables: initialamount, dollars, cents Local Variables: newamount, convertedamount (d) Member variables: initialamount, dollars, cents Argument variables: amount Local Variables: newamount, convertedamount 37. Suppose that f(n) is O(n 2 ) in Big Oh notation. Which of the following functions could be f(n)? (a) 2 n + 184n 2 (b) 5n 2 log n + 2 (c) 34n + 15n (d) 901n 3 6n 2 11

13 38. Consider the following class file: public class HDTV { private static int resolution = 0; public static int size = 0; public static void displaypicture() { System.out.println("Displaying picture at resolution: " + resolution ); public static void setresolution(int r) { resolution = r; public static void setsize(int s) { size = s; public static int getresolution() { return resolution; Which of the following statements would result in a compilation error? (a) HDTV.setResolution(720); (b) HDTV.resolution = 720; (c) int r = HDTV.getResolution(); (d) HDTV.size = 50; 39. What is the running time of binary search on an array with n elements in Big Oh notation? (a) O(n 2 ) (b) O(log n) (c) O(n log n) (d) O(n) 40. What happens if a class defines a method with the same name and parameters as a method in its superclass? (a) There is no problem because overriding methods is allowed. (b) The subclass method will be ignored. (c) The compiler automatically renames the subclass method. (d) The compiler gives an error. 12

14 41. Which one of the following statements about if statements is correct? (a) The conditional of an if statement must evaluate to the boolean type. (b) An if statement must include an else if statement. (c) An if statement must include an else statement. (d) None of the above is correct. 42. What does the following fragment of code print out? double x = -1; if ( x > 1) if ( x > 3 ) System.out.println("x is big."); else if( x > 2 ) System.out.println("x must be 3."); else { if (x < 0) System.out.println("x is too small."); else System.out.println("x is small."); (a) x must be 3. (b) x is small. (c) Nothing is printed out. (d) x is big. 43. What is the output of problem("bdcda")? public static void problem(string s) { int j = 0; char letter; for(int i = 0 ; i < s.length(); i++) { letter = s.charat(i); if (letter == a ) break; else if (letter == b ) continue; else if (letter == c ) j *= 2; else if (letter == d ) j++; System.out.println( j ); (a) 1 (b) 3 (c) 2 (d) 0 13

15 44. What is the output of the following code? public static void main(string[] args) { char initial = c ; switch (initial) { case j : System.out.print("John"); break; case c : System.out.print("Chuck"); case t : System.out.print("Ty"); break; case s : System.out.print("Scott"); default: System.out.print("All"); (a) JohnChuckTyScottAll (b) ChuckTy (c) Chuck (d) ChuckTyAll 45. Given the following code segment, what will be printed out? String s1 = new String("identical"); String s2 = new String("identical"); if( s1 == s2 ) System.out.print("Same1 "); else System.out.print("Different1 "); if( s1.equals( s2 ) ) System.out.println("Same2"); else System.out.println("Different2"); (a) Different1 Different2 (b) Same1 Different2 (c) Different1 Same2 (d) Same1 Same2 14

16 46. Suppose the size of array a passed into this method is 10. At most, how many times will the exchange() method be called? public static void sort(int[] a) { for (int i = 0; i < a.length; i++) { for (int j = i; j > 0; j--) { if (a[j-1] > a[j]) { exchange(a, j-1, j); else break; (a) 36 (b) 90 (c) 45 (d) How many int values can be held in the array declared below? int[][][] array = new int[5][4][1]; (a) 11 (b) 21 (c) 20 (d) Which of the following statements about constant values is not correct? (a) Constants can only be assigned a value once and will never change afterwards. (b) Private members can be declared as constants. (c) Static members cannot be declared as constants. (d) Constants are declared in Java with the final keyword 49. What is the index of the first element in an array? (a) 1 (b) 0 (c) It depends on the length of the array. (d) -1 15

17 50. What will the contents of numbers be after the following for loop is executed? int[] numbers = new int[5]; for(int i = 0; i < numbers.length; i++) numbers[i] = i*i; (a) {1, 4, 9, 16, 25 (b) {0, 1, 4, 9, 16 (c) {0, 0, 0, 0, 0 (d) {0, 1, 2, 3, What are the error(s) in the following code? String[] strings = new String[10]; for(int index = 0; index <= strings.length; index++) System.out.println(strings[index].length()); (a) The value of index goes past the last valid index in strings. (b) The code contains no error. (c) Both errors are present. (d) The elements of an object array should be initialized before they can be used. 52. Which of the following is not true about arrays? (a) The size of an array cannot change. (b) Everything in an array must have the same type. (c) An array is a data structure. (d) Arrays are never automatically filled with values when created. 53. What does the following code create? (Assume the first dimension is rows and the second dimension is columns). int[][] numbers = new int[3][]; for(int i = 0; i < numbers.length; i++) numbers[i] = new int[i+1]; (a) A two-dimensional array with 3 rows and 3 columns. (b) A ragged array with 3 rows, where the first row has 2 columns, the second row has 3 columns, and the third row has 4 columns. (c) This code will cause a run-time error. (d) A ragged array with 3 rows, where the first row has 1 column, the second row has 2 columns, and the third row has 3 columns. 16

18 54. Which is the correct way to get the Color object for the pixel at position (25, 30) from a Picture object called picture? (a) Color c = picture[25][30]; (b) Color c = picture[25][30].get(); (c) Color c = picture.get()[25][30]; (d) Color c = picture.get(25, 30); 55. Which is the correct way to get the blue intensity level from a Color object called color? (a) int blue = color.getrgb().getblue(); (b) int blue = getblue(color); (c) int blue = color.getblue(); (d) int blue = color[blue]; 56. What does the following code fragment do? Picture picture = new Picture(100, 100); for(int i = 0; i < picture.width(); i++){ for(int j = 0; j < picture.height(); j++){ Color c = new Color(255, 0, 0); picture.set(i, j, c); (a) Creates a 100x100 pixel picture that is completely blue. (b) Creates a 100x100 pixel picture that is completely red. (c) Shrinks an image down to 100x100 pixels. (d) Creates a mirror image of the original picture. 57. What does the following code fragment do? Picture p = new Picture("fish.jpg"); for(int i = 0; i < p.width(); i++){ for(int j = 0; j < p.height(); j++){ Color old = p.get(i, j); int r = old.getred(); int g = old.getgreen(); int b = old.getblue(); int x =.299*r +.587*g +.114*b; Color current = new Color(x, x, x); p.set(i, j, current); (a) Creates a blue-tinted version of fish.jpg. (b) Creates a rotated version of fish.jpg. (c) Creates a version of the file fish.jpg whose size has been reduced. (d) Creates a grayscale version of the file fish.jpg. 17

19 58. Which of the following is not true about colors and the Color class? (a) In the RGB model, (0,0,0) is the color white. (b) To use the Color class, you must import it using an import statement. (c) The Color class uses the RGB model. (d) In the Color class, each color component has an intensity value between 0 and Which of the following commands would you type into the terminal to execute a program whose source code is stored in YakAttack.java? (a) java YakAttack.class (b) java YakAttack (c) javac YakAttack (d) javac YakAttack.java 60. Which of the following statements regarding Java objects are true? I. Three common types of object methods are: constructors, accessors, and mutators. II. Objects contain members and methods; members are usually private while methods are usually public. III. A static method must be associated with a particular object. (a) I and II only (b) I and III only (c) I, II, and III (d) I only 18

CS 177 Spring 2009 Exam I

CS 177 Spring 2009 Exam I CS 177 Spring 2009 Exam I There are 40 multiple choice questions. Each one is worth 2.5 points. The total score for the exam is 100. Answer the multiple choice questions on the bubble sheet given. Fill

More information

CS 177 Spring 2010 Exam I

CS 177 Spring 2010 Exam I CS 177 Spring 2010 Exam I There are 25 multiple choice questions. Each one is worth 4 points. The total score for the exam is 100. Answer the multiple choice questions on the bubble sheet given. Fill in

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

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

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

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail. OOP in Java 1 Outline 1. Getting started, primitive data types and control structures 2. Classes and objects 3. Extending classes 4. Using some standard packages 5. OOP revisited Parts 1 to 3 introduce

More information

COS 126 General Computer Science Spring Written Exam 1

COS 126 General Computer Science Spring Written Exam 1 COS 126 General Computer Science Spring 2017 Written Exam 1 This exam has 9 questions (including question 0) worth a total of 70 points. You have 50 minutes. Write all answers inside the designated spaces.

More information

Introduction to Computer Science Midterm 3 Fall, Points

Introduction to Computer Science Midterm 3 Fall, Points Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

CS 177 Recitation. Week 9 Audio Processing

CS 177 Recitation. Week 9 Audio Processing CS 177 Recitation Week 9 Audio Processing Announcements Project 3 (final version) is due on Thursday (Oct 29) Any questions about the project? Questions? Sound Like light, sound is a wave We can t record

More information

JVM (java) compiler. A Java program is either a library of static methods (functions) or a data type definition

JVM (java) compiler. A Java program is either a library of static methods (functions) or a data type definition Programming Model Basic Structure of a Java Program The Java workflow editor (Code) P.java compiler (javac) P.class JVM (java) output A Java program is either a library of static methods (functions) or

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

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

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

More information

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

SPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each Your Name: Your Pitt (mail NOT peoplesoft) ID: Part Question/s Points available Rubric Your Score A 1-6 6 1 pt each B 7-12 6 1 pt each C 13-16 4 1 pt each D 17-19 5 1 or 2 pts each E 20-23 5 1 or 2 pts

More information

CS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit.

CS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit. Name CS 110 Practice Final Exam originally from Winter, 2003 Instructions: closed books, closed notes, open minds, 3 hour time limit. There are 4 sections for a total of 49 points. Part I: Basic Concepts,

More information

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Language Features. 1. The primitive types int, double, and boolean are part of the AP Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are

More information

Searching and Sorting (Savitch, Chapter 7.4)

Searching and Sorting (Savitch, Chapter 7.4) Searching and Sorting (Savitch, Chapter 7.4) TOPICS Algorithms Complexity Binary Search Bubble Sort Insertion Sort Selection Sort What is an algorithm? A finite set of precise instruc6ons for performing

More information

The Java language has a wide variety of modifiers, including the following:

The Java language has a wide variety of modifiers, including the following: PART 5 5. Modifier Types The Java language has a wide variety of modifiers, including the following: Java Access Modifiers Non Access Modifiers 5.1 Access Control Modifiers Java provides a number of access

More information

Admin. CS 112 Introduction to Programming. Recap: Exceptions. Summary: for loop. Recap: CaesarFile using Loop. Summary: Flow Control Statements

Admin. CS 112 Introduction to Programming. Recap: Exceptions. Summary: for loop. Recap: CaesarFile using Loop. Summary: Flow Control Statements Admin. CS 112 Introduction to Programming q Puzzle Day from Friday to Monday Arrays; Loop Patterns (break) Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email:

More information

COS 126 General Computer Science Fall Exam 1

COS 126 General Computer Science Fall Exam 1 COS 126 General Computer Science Fall 2005 Exam 1 This test has 9 questions worth a total of 50 points. You have 120 minutes. The exam is closed book, except that you are allowed to use a one page cheatsheet,

More information

a) Answer all questions. b) Write your answers in the space provided. c) Show all calculations where applicable.

a) Answer all questions. b) Write your answers in the space provided. c) Show all calculations where applicable. Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2008 January Exam Question Max Internal

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming Arrays; Loop Patterns (break) Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu Admin. q Puzzle Day

More information

Computer Science 1 Ah

Computer Science 1 Ah UNIVERSITY OF EDINBURGH course CS0077 COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS Computer Science 1 Ah Resit Examination Specimen Solutions Date: Monday 1st September 2003 Time: 09:30 11:00

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 #1 Fundamentals of Computer Science I Fall 2012

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

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

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

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

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

I. True/False: (2 points each)

I. True/False: (2 points each) CS 102 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2008 What is your name?: (2 points) There are three sections: I. True/False..............54 points; (27 questions, 2 points each)

More information

Programming overview

Programming overview Programming overview Basic Java A Java program consists of: One or more classes A class contains one or more methods A method contains program statements Each class in a separate file MyClass defined in

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

Last Class. Introduction to arrays Array indices Initializer lists Making an array when you don't know how many values are in it

Last Class. Introduction to arrays Array indices Initializer lists Making an array when you don't know how many values are in it Last Class Introduction to arrays Array indices Initializer lists Making an array when you don't know how many values are in it public class February4{ public static void main(string[] args) { String[]

More information

TeenCoder : Java Programming (ISBN )

TeenCoder : Java Programming (ISBN ) TeenCoder : Java Programming (ISBN 978-0-9887070-2-3) and the AP * Computer Science A Exam Requirements (Alignment to Tennessee AP CS A course code 3635) Updated March, 2015 Contains the new 2014-2015+

More information

CompuScholar, Inc. 9th - 12th grades

CompuScholar, Inc. 9th - 12th grades CompuScholar, Inc. Alignment to the College Board AP Computer Science A Standards 9th - 12th grades AP Course Details: Course Title: Grade Level: Standards Link: AP Computer Science A 9th - 12th grades

More information

Arrays. Eng. Mohammed Abdualal

Arrays. Eng. Mohammed Abdualal Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 9 Arrays

More information

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented Table of Contents L01 - Introduction L02 - Strings Some Examples Reserved Characters Operations Immutability Equality Wrappers and Primitives Boxing/Unboxing Boxing Unboxing Formatting L03 - Input and

More information

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2012

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

More information

Arrays. COMS W1007 Introduction to Computer Science. Christopher Conway 10 June 2003

Arrays. COMS W1007 Introduction to Computer Science. Christopher Conway 10 June 2003 Arrays COMS W1007 Introduction to Computer Science Christopher Conway 10 June 2003 Arrays An array is a list of values. In Java, the components of an array can be of any type, basic or object. An array

More information

CONTENTS: Array Usage Multi-Dimensional Arrays Reference Types. COMP-202 Unit 6: Arrays

CONTENTS: Array Usage Multi-Dimensional Arrays Reference Types. COMP-202 Unit 6: Arrays CONTENTS: Array Usage Multi-Dimensional Arrays Reference Types COMP-202 Unit 6: Arrays Introduction (1) Suppose you want to write a program that asks the user to enter the numeric final grades of 350 COMP-202

More information

COS 126 General Computer Science Fall Exam 1

COS 126 General Computer Science Fall Exam 1 COS 126 General Computer Science Fall 2008 Exam 1 This test has 11 questions worth a total of 50 points. You have 120 minutes. The exam is closed book, except that you are allowed to use a one page cheatsheet,

More information

I have neither given nor received any assistance in the taking of this exam.

I have neither given nor received any assistance in the taking of this exam. UC Berkeley Computer Science CS61B: Data Structures Midterm #1, Spring 2017 This test has 10 questions worth a total of 80 points, and is to be completed in 110 minutes. The exam is closed book, except

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

Object Oriented Programming. Java-Lecture 6 - Arrays

Object Oriented Programming. Java-Lecture 6 - Arrays Object Oriented Programming Java-Lecture 6 - Arrays Arrays Arrays are data structures consisting of related data items of the same type In Java arrays are objects -> they are considered reference types

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

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8 Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

Arrays: Higher Dimensional Arrays. CS0007: Introduction to Computer Programming

Arrays: Higher Dimensional Arrays. CS0007: Introduction to Computer Programming Arrays: Higher Dimensional Arrays CS0007: Introduction to Computer Programming Review If the == operator has two array variable operands, what is being compared? The reference variables held in the variables.

More information

Last Class. More on loops break continue A bit on arrays

Last Class. More on loops break continue A bit on arrays Last Class More on loops break continue A bit on arrays public class February2{ public static void main(string[] args) { String[] allsubjects = { ReviewArray, Example + arrays, obo errors, 2darrays };

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

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

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

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

COS 126 Midterm 1 Written Exam Fall 2011

COS 126 Midterm 1 Written Exam Fall 2011 NAME: login id: Precept: COS 126 Midterm 1 Written Exam Fall 2011 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

PROGRAMMING FUNDAMENTALS

PROGRAMMING FUNDAMENTALS PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write

More information

What is an algorithm?

What is an algorithm? /0/ What is an algorithm? Searching and Sorting (Savitch, Chapter 7.) TOPICS Algorithms Complexity Binary Search Bubble Sort Insertion Sort Selection Sort A finite set of precise instrucons for performing

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

CMPS 12A Winter 2006 Prof. Scott A. Brandt Final Exam, March 21, Name:

CMPS 12A Winter 2006 Prof. Scott A. Brandt Final Exam, March 21, Name: CMPS 12A Winter 2006 Prof. Scott A. Brandt Final Exam, March 21, 2006 Name: Email: This is a closed note, closed book exam. There are II sections worth a total of 200 points. Plan your time accordingly.

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

Computer Programming C++ (wg) CCOs

Computer Programming C++ (wg) CCOs Computer Programming C++ (wg) CCOs I. The student will analyze the different systems, and languages of the computer. (SM 1.4, 3.1, 3.4, 3.6) II. The student will write, compile, link and run a simple C++

More information

Java for Non Majors Spring 2018

Java for Non Majors Spring 2018 Java for Non Majors Spring 2018 Final Study Guide The test consists of 1. Multiple choice questions - 15 x 2 = 30 points 2. Given code, find the output - 3 x 5 = 15 points 3. Short answer questions - 3

More information

CS 1302 Chapter 9 (Review) Object & Classes

CS 1302 Chapter 9 (Review) Object & Classes CS 1302 Chapter 9 (Review) Object & Classes Reference Sections 9.2-9.5, 9.7-9.14 9.2 Defining Classes for Objects 1. A class is a blueprint (or template) for creating objects. A class defines the state

More information

CS 1316 Exam 1 Summer 2009

CS 1316 Exam 1 Summer 2009 1 / 8 Your Name: I commit to uphold the ideals of honor and integrity by refusing to betray the trust bestowed upon me as a member of the Georgia Tech community. CS 1316 Exam 1 Summer 2009 Section/Problem

More information

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

Computer Science II (20073) Week 1: Review and Inheritance Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system

More information

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled Interpreted vs Compiled Python 1 Java Interpreted Easy to run and test Quicker prototyping Program runs slower Compiled Execution time faster Virtual Machine compiled code portable Java Compile > javac

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

Introduction to Java

Introduction to Java Introduction to Java Module 1: Getting started, Java Basics 22/01/2010 Prepared by Chris Panayiotou for EPL 233 1 Lab Objectives o Objective: Learn how to write, compile and execute HelloWorld.java Learn

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

CSE 20. SAMPLE FINAL Version A Time: 180 minutes. The following precedence table is provided for your use:

CSE 20. SAMPLE FINAL Version A Time: 180 minutes. The following precedence table is provided for your use: CSE 20 SAMPLE FINAL Version A Time: 180 minutes Name The following precedence table is provided for your use: Precedence of Operators ( ) - (unary),!, ++, -- *, /, % +, - (binary) = = =,!= &&

More information

1 Shyam sir JAVA Notes

1 Shyam sir JAVA Notes 1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write

More information

Use the scantron sheet to enter the answer to questions (pages 1-6)

Use the scantron sheet to enter the answer to questions (pages 1-6) Use the scantron sheet to enter the answer to questions 1-100 (pages 1-6) Part I. Mark A for True, B for false. (1 point each) 1. Abstraction allow us to specify an object regardless of how the object

More information

Use the Scantron sheets to write your answer. Make sure to write your Purdue ID (NOT Purdue Login ID) and your name on the Scantron answer sheet.

Use the Scantron sheets to write your answer. Make sure to write your Purdue ID (NOT Purdue Login ID) and your name on the Scantron answer sheet. Department of Computer Science Purdue University, West Lafayette Fall 2011: CS 180 Problem Solving and OO Programming Final Examination: Part A. You may consult the textbook and your hand written notes.

More information

Inheritance (Part 5) Odds and ends

Inheritance (Part 5) Odds and ends Inheritance (Part 5) Odds and ends 1 Static Methods and Inheritance there is a significant difference between calling a static method and calling a non-static method when dealing with inheritance there

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

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

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java

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

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

CS 170 Exam 2. Version: A Fall Name (as in OPUS) (print): Instructions:

CS 170 Exam 2. Version: A Fall Name (as in OPUS) (print): Instructions: CS 170 Exam 2 Version: A Fall 2015 Name (as in OPUS) (print): Section: Seat Assignment: Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do

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

Instructions. This exam has 7 questions, worth 10 points each. You have 50 minutes.

Instructions. This exam has 7 questions, worth 10 points each. You have 50 minutes. COS 126 Written Exam 1 Spring 18 Instructions. This exam has 7 questions, worth 10 points each. You have 50 minutes. Resources. You may reference your optional one-sided 8.5-by-11 handwritten "cheat sheet"

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

NATIONAL UNIVERSITY OF SINGAPORE

NATIONAL UNIVERSITY OF SINGAPORE NATIONAL UNIVERSITY OF SINGAPORE SCHOOL OF COMPUTING TERM TEST #1 Semester 1 AY2006/2007 CS1101X/Y/Z PROGRAMMING METHODOLOGY 16 September 2006 Time Allowed: 60 Minutes INSTRUCTIONS 1. This question paper

More information

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function

More information

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

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks: كلية الحاسبات وتقنية المعلوما Exam 2 Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: November 22, 2015 Student Name: Student ID: Total Marks: 40 Obtained Marks: Instructions: Do not open this

More information

This exam is open book. Each question is worth 3 points.

This exam is open book. Each question is worth 3 points. This exam is open book. Each question is worth 3 points. Page 1 / 15 Page 2 / 15 Page 3 / 12 Page 4 / 18 Page 5 / 15 Page 6 / 9 Page 7 / 12 Page 8 / 6 Total / 100 (maximum is 102) 1. Are you in CS101 or

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 2008 What is your name?: There are three sections: I. True/False..............60 points; (30 questions, 2 points each) II. Multiple

More information

1 Inheritance (8 minutes, 9 points)

1 Inheritance (8 minutes, 9 points) Name: Career Account ID: Recitation#: 1 CS180 Spring 2011 Exam 2, 6 April, 2011 Prof. Chris Clifton Turn Off Your Cell Phone. Use of any electronic device during the test is prohibited. Time will be tight.

More information

Example: Computing prime numbers

Example: Computing prime numbers Example: Computing prime numbers -Write a program that lists all of the prime numbers from 1 to 10,000. Remember a prime number is a # that is divisible only by 1 and itself Suggestion: It probably will

More information

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 Instructor: K. S. Booth Time: 70 minutes (one hour ten minutes)

More information

Question: Total Points: Score:

Question: Total Points: Score: CS 170 Exam 1 Section 001 Fall 2014 Name (print): Instructions: Keep your eyes on your own paper and do your best to prevent anyone else from seeing your work. Do NOT communicate with anyone other than

More information

1. AVL Trees (10 Points)

1. AVL Trees (10 Points) CSE 373 Spring 2012 Final Exam Solution 1. AVL Trees (10 Points) Given the following AVL Tree: (a) Draw the resulting BST after 5 is removed, but before any rebalancing takes place. Label each node in

More information

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade; Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The

More information

Programming Language Concepts: Lecture 2

Programming Language Concepts: Lecture 2 Programming Language Concepts: Lecture 2 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 2, 19 January 2009 Classes and

More information

Chapter 6. Arrays. Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays

Chapter 6. Arrays. Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays Chapter 6 Arrays Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays Chapter 6 Java: an Introduction to Computer Science & Programming

More information

Java Programming Basics. COMP 401, Spring 2017 Lecture 2

Java Programming Basics. COMP 401, Spring 2017 Lecture 2 Java Programming Basics COMP 401, Spring 2017 Lecture 2 AverageHeightApp take 2 Same as before, but with Eclipse. Eclipse Workspace CreaJng new project CreaJng a new package CreaJng new class Running a

More information

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers) Review Final exam Final exam will be 12 problems, drop any 2 Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers) 2 hours exam time, so 12 min per problem (midterm 2 had

More information

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. CMSC 131: Chapter 28 Final Review: What you learned this semester The Big Picture Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. Java

More information

COS 126 Midterm 1 Written Exam Fall 2012

COS 126 Midterm 1 Written Exam Fall 2012 Name:!! Login ID:!!! Precept: COS 126 Midterm 1 Written Exam Fall 2012 is test has 8 questions, weighted as indicated. e exam is closed book, except that you are allowed to use a one page single-sided

More information

CS101 Part 2: Practice Questions Algorithms on Arrays, Classes and Objects, String Class, Stack Class

CS101 Part 2: Practice Questions Algorithms on Arrays, Classes and Objects, String Class, Stack Class CS1 Part 2: Algorithms on Arrays, Classes and Objects, String Class, Stack Class 1. Write a method that, given two sorted arrays of integers, merges the two arrays into a single sorted array that is returned.

More information