spring2010exam2

spring2010exam2 - CS 177 Spring 2010 Exam II There are 25...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 177 Spring 2010 Exam II 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 the Instructor, Course, Signature, Test, and Date blanks in the bubble sheet. For “Instructor” put your RECITATION INSTRUCTOR’S LAST NAME GIVEN BELOW. For “Course” put CS 177. For “Test/Quiz” put 02 . Fill in the bubbles that correspond to your name, section and Student ID in the bubble sheet. For your section number, use the four digits of the SECTION NUMBER of your recitation section. Consult the following list: 0001 FRI 07:30 LWSN B134 Parantap Roy 0002 THU 09:30 BRNG B238 Cheng Wang 0003 FRI 03:30 LWSN 1106 Serkan Uzunbaz 0004 THU 12:30 BRNG B230 Mohammad Kazi 0005 THU 12:30 BRNG 1255 Parantap Roy 0006 FRI 04:30 HAAS G066 Serkan Uzunbaz 0019 THU 10:30 LWSN 1106 Tyler Wykoff 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_________________________________ Page | 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Answer Questions 1 and 2 based on the following program: Filename: TestSuite.java public class TestSuite { public static void testA(int x1) { x1 = 1000; } public static int testB(int[] ab, int len) { int sum = 0; for (int i = 0; i < len; i++) sum += ab[i]; return sum; } public static void main(String[] args){ int[] xyz = new int[10]; int input = 0,sum; input = StdIn.readInt(); for (int i = 1; i <= input; i++){ xyz[i-1] = i; } sum = testB(xyz, input); testA(input); System.out.println("Number = " + input + "\tSum = " + sum); } } Q1 . The output of the above program for user input 10 is the following: A. Number = 0 Sum = 55 B. Number = 10 Sum = 55 C. Number = 1000 Sum = 55 D. The program will not compile. Q2. Assume you have the function definition: public static int testB(int[] ab, int len), and the function call: sum = testB(xyz, input) . Identify the correct statement. Page | 2
Background image of page 2
A. Array xyz is passed by reference and integer input is passed by value. B. Array xyz is passed by reference and integer input is passed by reference. C. Array xyz is passed by value and integer input is passed by value. D. Array xyz and integer input are not passed to the function as their types don’t match.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

spring2010exam2 - CS 177 Spring 2010 Exam II There are 25...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online