CS 132 Midterm Exam Winter 2002

Similar documents
CS 122/132 Midterm Exam Winter 2003

CS 132 Midterm Exam Spring 2004

CS 132 Midterm Exam Fall 2004

CS 349 Midterm Exam Spring 2014

CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Signature: Question # Out Of Marks Marker Total

CS246 Software Abstraction and Specification Final Examination

CS348: INTRODUCTION TO DATABASE MANAGEMENT (Winter, 2011) FINAL EXAMINATION

Dalhousie University CSCI 2132 Software Development Winter 2018 Midterm Examination II March 12 15:37-16:24

CS 132 Final Exam Winter 2005

EXAMINATION INSTRUCTIONS

EXAMINATION INSTRUCTIONS

Introduction to Computer Science II (CSI 1101)

Prelim 1. CS 2110, March 15, 2016, 7:30 PM Total Question Name True False. Short Answer

Midterm Exam (REGULAR SECTION)

CSE351 Winter 2016, Final Examination March 16, 2016

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer

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.

Midterm Exam #2 (Version A) CS 122A Winter 2017

Section 003 Fall CS 170 Exam 2. Name (print): Instructions:

CSE 131 Introduction to Computer Science Fall Exam I

CS 367: Introduction to Data Structures Midterm Sample Questions

Prelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants

Midterm Exam 2 CS 455, Spring 2011

CS164: Midterm I. Fall 2003

CSC207 Quiz 1 Solutions Monday 6 February 2017, 12:15 PM. 1. (A) (B) (C) (D) (E) 7. Nothing, does not run true false

CSE 131 Introduction to Computer Science Fall Exam I

Lecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting

Problem Points Score Grader Total 75

SYSC Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

Midterm Examination COMP 304B 2004: Object-oriented Design

CS 247 Software Engineering Principles Midterm Examination **Solutions** Spring 2017

Ryerson University Vers HAL6891A-05 School of Computer Science CPS109 Midterm Test Fall 05 page 1 of 6

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

CSE 131S Introduction to Computer Science Summer SON Exam I

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

Student Number: UTORid: Question 0. [1 mark] Read and follow all instructions on this page, and fill in all fields.

Prelim 1. CS 2110, October 1, 2015, 5:30 PM Total Question Name True Short Testing Strings Recursion

CS 2334: Programming Structures and Abstractions: Exam 1 October 3, 2016

CSE 131S Introduction to Computer Science Summer SON Exam III

ECOR Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer

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

CS 1110 Prelim 1 March 10, 2015

CSE 131 Introduction to Computer Science Fall Exam I

Please note that if you write the mid term in pencil, you will not be allowed to submit a remark request.

UNIVERSITY REGULATIONS

Duke Law Exam Information Fall 2018

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 304: MIDTERM EXAMINATION SET A OCTOBER 2016

Comp2310 & Comp6310 Systems, Networks and Concurrency

CS 307 Midterm 1[corrected] Spring 2008

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

Problem Points Score Grader Total 100

Designing Classes. Appendix D. Slides by Steve Armstrong LeTourneau University Longview, TX 2007, Prentice Hall

Common Misunderstandings from Exam 1 Material

Object Class. EX: LightSwitch Class. Basic Class Concepts: Parts. CS257 Computer Science II Kevin Sahr, PhD. Lecture 5: Writing Object Classes

Largest Online Community of VU Students

Final exam. CS 2110, December 15, 2016, 9:00AM

CS 10, Fall 2015, Professor Prasad Jayanti

CS153: Midterm (Winter 19)

CS 455 Midterm Exam 1 Spring 2011 [Bono] Feb. 17, 2011

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

EXAMINATION INSTRUCTIONS

CS 314 Exam 2 Spring 2018

THE UNIVERSITY OF WESTERN AUSTRALIA. School of Computer Science & Software Engineering CITS1001 OBJECT-ORIENTED PROGRAMMING AND SOFTWARE ENGINEERING

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 2

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #1 Examination 12:30 noon, Tuesday, February 14, 2012

CS 1110 Prelim 1 March 15th, 2016

Midterm Exam #2 (Version B) CS 122A Spring 2018

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

Lecture 4 Specifications

Data Structure (CS301)

CS 101 Spring 2007 Midterm 2 Name: ID:

Instructions. Quiz #2. Name: Solutions Student Number: Signature:

CIS 120 Midterm II November 8, Name (printed): Pennkey (login id):

ECOM 2324 COMPUTER PROGRAMMING II

Exam Percentage: / 55 = %

READ ALL INSTRUCTIONS

CS Exam 2 - Spring 2010

CS 113 MIDTERM EXAM 2 SPRING 2013

Final Exam. Kenneth J. Goldman December 18, Name: Student ID Number: Signature:

Last name:... First name:... Department (if not D-INFK):...

CS162, Spring 2004 Discussion #6 Amir Kamil UC Berkeley 2/26/04

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

COMP 401 Midterm. Tuesday, Oct 18, pm-3:15pm. Instructions

CSE373 Fall 2013, Midterm Examination October 18, 2013

C12a: The Object Superclass and Selected Methods

CS1004: Intro to CS in Java, Spring 2005

CS 159 Midterm #1 Review Questions

Project 1. due date Sunday July 8, 2018, 12:00 noon

I. True/False: (2 points each)

1 Inheritance (8 minutes, 9 points)

Introduction to Computing II (ITI 1121) Midterm Examination

CS 314 Exam 1 Fall 2016

CS 101 Spring 2006 Final Exam Name: ID:

CSC 207H Fall L Java Quiz Duration 25 minutes Aids allowed: none

Final Exam CS 152, Computer Programming Fundamentals May 9, 2014

UMBC CMSC 331 Final Exam

ATSD Testing System Faculty Instructions

CS 1331 Exam 1 ANSWER KEY

Transcription:

Date: 18-Feb-2002 Time: 7:00 pm - 9:00 pm Permitted Aids: None CS 132 Midterm Exam Winter 2002 Printed Last Name: Initials: ID: Signature: Please check off your PRActicum section from the list below: Byron Weber Becker Steven Furino Arnie Dyck Wed @ 10:30 Thurs @ 10:30 unsure Wed @ 12:30 Wed @ 2:30 unsure Wed @ 8:30 Thurs @ 8:30 unsure Instructions: (Read carefully before the exam begins): 1. Before the exam begins, make certain that you have 11 pages in this booklet and 1 yellow paper. 2. Before the exam begins, fill in information about yourself on this page. 3. The yellow paper contains a case study which forms the basis for almost every question in the exam. When the exam begins, turn the yellow page over and read it carefully. 4. Answer all questions in this booklet. If additional space is required, use page 10. Label work clearly, both on page 10 and where the question is asked. 5. Additional paper is available upon request. 6. The marks assigned to each question are shown at the beginning of the question. Use this information to organize your time effectively. There are a total of 100 marks available. 7. Some multiple choice questions ask you to circle all of the correct answers. These questions have a penalty for wrong answers. Other multiple choice questions ask you to circle one answer. These questions do not have a penalty for wrong answers. 8. Questions will not be interpreted. Proctors will confirm or deny errors only. If you consider the wording of a question to be ambiguous, state your assumptions clearly and proceed to answer the question to the best of your ability. Your assumptions may not trivialize the question. 9. Documentation is always appreciated, but is not required unless explicitly requested. 10. Cheating is an academic offense. Your signature on this exam indicates that you understand and agree to the University s policies regarding cheating on exams. Marks: 1-4. / 14 5. / 10 6-7. / 13 8. / 32 9. / 20 10. / 11 / 100 Page 1 of 11

1. [03] Suppose a method in the TextUI class has a student ID stored in the local variable idnum. Circle all of the following that could be used to print the average for the specified student. a. Student s = this.model.find(idnum); System.out.println("Avg = " + s.calcavg()); b. System.out.println("Avg = " + this.calcavg()); c. Student s = (Student)this.students.elementAt(idNum); System.out.println(("Avg = " + s.calcavg()); d. double avg = this.model.find(idnum).calcavg(); System.out.println("Avg = " + avg); e. None of a, b, c, or d. 2. [05] A student is in trouble if any of the following are true: more than one assignment has not been submitted more than one assignment has been excused the average is less than 60% Assume that the following Boolean expressions are in the Student class. Circle all of the expressions that return true if a student is in trouble and false otherwise. a. this.numdns() > 1 && this.numexc() > 1 && this.calcavg() < 0.60 b. this.numdns() > 1 this.numexc() > 1 this.calcavg() < 0.60 c.!(this.numdns() <= 1 && this.numexc() <= 1 && this.calcavg() >= 0.60) d.!(this.numdns() <= 1 this.numexc() <= 1 this.calcavg() >= 0.60) e. (this.numdns() + this.numexc()) > 1 this.calcavg() < 0.60 3. [03] Given the declaration Student[] students = new Student[10]; which one of the following is the most likely explanation of an ArrayOutOfBoundsError? a. The program attempted to access students[10]. b. The program did not allocate memory for the students array. c. The program did not fill the students array with data. d. The program did not declare the students array. e. None of the above are possible explanations for an ArrayOutOfBoundsError. 4. [03] Given the declaration Student[] students = new Student[10]; which one of the following is the most likely explanation of a NullPointerException? a. The program attempted to access students[10]. b. The program did not allocate memory for the students array. c. The program did not fill the students array with data. d. The program did not declare the students array. e. None of the above are possible explanations for a NullPointerException. Page 2 of 11

5. [10] Implement the calcavg method in the Student class. Assume that every element of the array, marks, has a value and that at least one is not EXC. Recall that a mark of DNS (did not submit) is recorded in the array as 3001 and an excused mark, EXC, is recorded as 3002. DNS contributes 0 to the average; EXC is not included in the average at all. public class Student extends Object { private int id; private String givenname; private String surname; private int[] marks; private final static int DNS = 3001; private final static int EXC = 3002; public Student(int nummarks,...) {... public double calcavg() Examples: Marks Avg 70 70 90 90 80 3002 3002 80 90 85 80 3001 80 80 60 Page 3 of 11

6. [05] Professor Furino wants to list of all the students in his section (104) that have at least one DNS or EXC mark. Given a Student object, s, the test to select these students could be written as s.getsection() == 104 && (s.numdns() > 0 s.numexc() > 0) Use DeMorgan s Laws to find all the students who are not in this list. Show your work. 7. [08] A method signature is the first line of the method. It includes the visibility modifier (e.g.: public), the return type, the name of the method and the parameters. Write a signature for a method to solve each of the following tasks: a. [02] In ClassList, a method returning a single string containing all of the names of students in one specified section. b. [02] In ClassList, a method returning the ID numbers of students in one specified section. c. [02] In ClassList, a method returning the student objects for students in one or more specified sections. d. [02] In ClassList, a method returning the student objects for students in one or more specified sections that have a mark higher than a specified minimum. Page 4 of 11

8. [32] Using the design presented in the UML, implement the ClassList and Student constructors to read a data file using the format shown in the program specification. You must read the file only once, due to the inefficiency of file operations. Put the code for ClassList on this page and the code for Student on the next page. package markprogram; public class ClassList extends Object { private String coursenum; private String coursename; private Student[] students; private int numstudents; public ClassList(String filename) { // ClassList Page 5 of 11

8. (Continued) package markprogram; public class Student extends Object { private int id; private String lastname; private String givenname; private int sectionnum; private int[] marks; private final static int DNS = 3001; private final static int EXC = 3002; public Student(int nummarks, ) //Student Page 6 of 11

9. [20] Listed below are five attempts to implement the find method in the ClassList class. The find method is designed to return the Student object corresponding to the given ID or null if it isn t found. Each attempt contains an error. Find the error and fix it. In all cases your changes must be the smallest change that will fix the problem. In one case, that is 3 lines added or changed; in the remaining cases only 1 line must be added or changed. public Student find(int anid) public Student find4(int anid) { Student s = null; int i = 0; while (s == null) { if(this.students[i].getid() == anid) { s = this.students[i]; i ++; return s; public Student find2(int anid) { int i = 0; while (i >= this.numstudents this.students[i].getid() == anid) { i++; if (i > this.numstudents) { return null; else { return this.students[i]; public Student find(int anid) { boolean found = false; int i = 0; while (i < this.numstudents &&!found) { int i = 0; while (true) { if(i == this.numstudents ) { return null; if(this.students[i].getid()!= anid) { return this.students[i]; i++; public Student find5(int anid) { boolean found = false; for(int i=0; i<this.numstudents; i++) { if (this.students[i].getid() == anid) { found = (this.students[i].getid() == anid); { found = true; if (found) if (found) { return this.students[i]; { return this.students[i]; else else Page 7 of 11

{ return null; { return null; Page 8 of 11

10. [11] The users of the marks program would like to have more detail for each mark. The program will be changed to store each mark in its own object. Design this new class. It must have services to return the mark in a string so it can be easily displayed; for example, 70, DNS, or EXC. return the numeric equivalent of this mark. return a comment for the mark. determine if the mark should be included in average calculations. determine if the mark is a DNS. determine if the mark is an EXC. add a comment to an existing mark. replace a mark with a new value, keeping track of the fact that it was modified. Provide an appropriate constructor. Do the following: Complete your design of the Mark class in the UML class diagram on the right. Make the one change to the Student class that is required to use the Mark class. Show the relationship between the classes. Student -int id -String lastname -String givenname -int sectionnum -int[] marks -int nummarks Mark +Student(...) +double calcavg() +int getid() +String getname() +int getsection() +int numdns() +int numexc() +String tostring() Page 9 of 11

Page 10 of 11

Page 11 of 11