CS 113 MIDTERM EXAM 2 SPRING 2013

Similar documents
CS170 Introduction to Computer Science Midterm 2

CS 113 PRACTICE FINAL

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

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

Instruction to students:

Chapter 8 Objects and Classes Dr. Essam Halim Date: Page 1

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Midterm Exam 2 CS 455, Spring 2011

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

2 What are the differences between constructors and methods?

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

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

Problem Grade Total

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch

CS 455 Midterm Exam 2 Fall 2015 [Bono] Nov. 10, 2015

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

University of Palestine. Mid Exam Total Grade: 100

CS 455 Final Exam Fall 2012 [Bono] Dec. 17, 2012

CS 455 Midterm Exam 1 Spring 2015 [Bono] Thursday, Feb. 19, 2015

CSCI 1226 Second Midterm Test

CS2401 QUIZ 5 February 26, questions / 20 points / 20 minutes NAME:..

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

Q1: Functions / 33 Q2: Arrays / 47 Q3: Multiple choice / 20 TOTAL SCORE / 100 Q4: EXTRA CREDIT / 10

Final Examination Semester 3 / Year 2008

Midterm Exam 2 CS 455, Spring 2013

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

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

CS 305j Midterm 2 Fall 2006

Computer Programming, I. Laboratory Manual. Final Exam Solution

Practice Midterm 1. Problem Points Score TOTAL 50

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

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

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

CSE 11 Midterm Fall 2012

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a

CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam

CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2013

CIS 265 Summer 2015 Exam 1 First Name Last Name

Practice Questions for Chapter 9

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

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

Final Exam COMP Fall 2004 Dec 16, 2004

CS 455 Midterm Exam 1 Fall 2017 [Bono] Thursday, Sep. 28, 2017

COS 126 General Computer Science Spring Written Exam 1

Midterm Exam 2 CS 455, Spring 2015

CS 116 Week 8 Page 1

CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016

Midterm Exam 2 CS 455, Spring 2014

CS 61B Summer 2005 (Porter) Midterm 2 July 21, SOLUTIONS. Do not open until told to begin

University of Massachusetts Amherst, Electrical and Computer Engineering

CS 455 Midterm 2 Spring 2018 [Bono] Apr. 3, 2018

CS 307 Midterm 2 Spring 2011

CIT Special final examination

Islamic University of Gaza Faculty of Engineering Computer Engineering Department

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

CS 101 Fall 2006 Midterm 3 Name: ID:

Name: Username: I. 20. Section: II. p p p III. p p p p Total 100. CMSC 202 Section 06 Fall 2015

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001

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

UMBC CMSC 331 Final Exam

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

CMSC132 Summer 2018 Midterm 1

CSC 240 Computer Science III Spring 2018 Midterm Exam. Name

public static String[] manyme() {

Department of Networks College of Bardarash Technical Institute DUHOK Polytechnic University Subject: Programming Fundamental by JAVA Course Book

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

COSC 1010 Introduction to Computer Programming

CS 101 Exam 2 Spring Id Name

Page 1 / 3. Page 2 / 18. Page 3 / 8. Page 4 / 21. Page 5 / 15. Page 6 / 20. Page 7 / 15. Total / 100. Pledge:

York University AS/AK/ITEC INTRODUCTION TO DATA STRUCTURES. Midterm Sample I. Examiner: S. Chen Duration: One Hour and 30 Minutes

CS171 Midterm Exam. October 29, Name:

CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015

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

RAIK 183H Examination 2 Solution. November 11, 2013

Questions Answer Key Questions Answer Key Questions Answer Key

I. True/False: (2 points each)

Midterm Exam CS 251, Intermediate Programming March 6, 2015

CSE 11 Midterm Fall 2009

CS 1302 Chapter 9 (Review) Object & Classes

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

Midterm Exam CS 251, Intermediate Programming March 12, 2014

CIS 110 Introduction to Computer Programming Spring 2016 Midterm

Recitation 3 Class and Objects

CS 302 Week 9. Jim Williams

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

I. True/False: (2 points each) On your bubble form fill out a for true and b for false.

RAIK 183H Examination 2 Solution. November 10, 2014

CS 101 Spring 2007 Midterm 2 Name: ID:

Midterm Exam 2 CS 455, Fall 2013

CS 101 Spring 2006 Final Exam Name: ID:

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

Final Exam. COMP Summer I June 26, points

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

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

Name Section Number. CS210 Exam #3 *** PLEASE TURN OFF ALL CELL PHONES*** Practice

Name CIS 201 Midterm II: Chapters 1-8

CSCS 261 Programming Concepts Exam 2 Fall EXAM 2 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

CS 455 Midterm Exam 1 Fall 2010 [Bono] Sept. 29, 2010

Csci 102: Sample Exam

Transcription:

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 partial credit for questions 16-18. If you finish early, use the extra time to double check your work. You may not use notes, books or electronic devices of any sort. All cell phones and other mobile devices must be turned off during the exam. Good luck! Name Student ID Section Answers for Questions 1 to 15 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 Q13 Q14 Q15 EXAM SCORES Q1-Q15 Q16 Q17 Q18 TOTAL

MULTIPLE CHOICE. (4 points each) Questions 1 2 are based on the following method: void nprint(string message, int n) { while (n > 0) { System.out.print(message); n--; 1) What is the printout of the call nprint("a", 4)? A. aaaaa B. aaaa C. aaa D. Invalid call 2) What is k after invoking nprint( A message, k+1)? int k = 2; nprint("a message", k+1); A. 0 B. 1 C. 2 D. 3 3) What is the output for y? int y = 0; for (int i = 0; i<10; ++i) { y += i; System.out.print(y); A. 45 B. 9 C. 10 D. 11 4) Given the array declaration below, list[1]is int[] list = {1, 2, 3, 4; A. 0 B. 1 C. 2 D. 3 E. undefined

5) What is the value in count after the following loop is executed? int count = 0; do { System.out.println("Welcome to Java"); count++; while (count < 9); System.out.println(count); A. 9 B. 8 C. 11 D. 10 6) When invoking a method with an object argument, is passed. A. the object is copied, then the reference of the copied object B. a copy of the object C. the contents of the object D. the reference of the object 7) is invoked to create an object. A. The main method B. A method with a return type C. A method with the void return type D. A constructor E. A class 8) Given the declaration Circle x = new Circle(), which of the following statement is most accurate. A. x contains an object of the Circle type. B. You can assign an int value to x. C. x contains a reference to a Circle object. D. x contains an int value. 9) Given the following statement int[ ] list = new int[10]; list.length has the value A. 10 B. 9 C. 11 D. The value depends on how many integers are stored in list..

10) In the following code, what is the printout for list2? class Test { public static void main(string[] args) { int[] list1 = {1, 2, 3; int[] list2 = {1, 2, 3; list2 = list1; list1[0] = 0; list1[1] = 1; list2[2] = 2; for (int i = 0; i < list2.length; i++) System.out.print(list2[i] + " "); A. 1 2 3 B. 1 1 1 C. 0 1 2 D. 0 1 3 11) Consider the following code fragment: int[] list = new int[10]; for (int i = 0; i <= list.length; i++) { list[i] = (int)(math.random() * 10); Which of the following statements is true? A. list.length must be replaced by 10 B. The loop body will execute 10 times, filling up the array with random numbers. C. The loop body will execute 10 times, filling up the array with zeros. D. The code has a runtime error indicating that the array is out of bound. 12) What is balance after the following code is executed? int balance = 10; while (balance >= 1) { if (balance < 9) continue; balance = balance - 9; A. 0 B. 2 C. The loop does not end D. 1 E. -1

13) Suppose array a is int[] a = {1, 2, 4;, what is a[1] - a[2]? A. 1 B. -1 C. 2 D. -2 14) What is y after the following switch statement? int x = 0; int y = 0; switch (x + 1) { case 0: y = 1; break; case 1: y = 2; break; default: y = 3; A. 1 B. 2 C. 0 D. 3 15) Analyze the following code. What is the value of count displayed? public class Count { private int count; public Count (int c) { count = c; public Count () { count = 1; public int getcount () { return count; public void setcount (int c) { count=c; public class Test { public static void main (String[] args) { Count mycount = new Count(); int times = 0; for (int i = 0; i < 100; i++) increment(mycount, times); System.out.println("count is " + mycount.getcount()); System.out.println("times is " + times); public static void increment(count c, int times) { int temp=c.getcount(); temp++; c.setcount(temp); times++; A. 98 B. 101 C. 100 D. 99

Write your answer in the space provided. 16) (20 points) Define a class named Student that contains: An int data field named age that stores the age of a student. A String data field named sid that represents the student id. A constructor that accepts and creates a student object with the specified age and student id. The getter and setter methods for all data field. A tostring method that returns student information including the student id and age. The equals method that returns true if two students have same id s and false otherwise. A method findyoungest() that returns the youngest student object.

Write your answer in the space provided. 17) (15 points) Write an application TestStudent with a main method that creates two Student objects with the following specifications: student1: 21 years old, sid= 123456789 student2: 19 years old, sid= 987654321 The method finds the youngest student and prints to the screen the information about that student.

Write your answer in the space provided. 18) (20 points) A method named summit that accepts 2 integer arrays named gamma and delta. If the arrays are the same size the method will return an array of the sum of the corresponding elements. If they are of different sizes the method will return an array as big as the smallest among gamma and delta arrays, where all of the elements are set to 5.