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

Similar documents
CS111: PROGRAMMING LANGUAGE II

CS 101 Exam 2 Spring Id Name

CS 455 Midterm Exam 2 Fall 2016 [Bono] November 8, 2016

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

QUIZ 2 Introduction to Computer Science (COMP 250) Mon. March 2, 2009 Professor Michael Langer

Csci 102: Sample Exam

CS171 Midterm Exam. October 29, Name:

Islamic University of Gaza Faculty of Engineering Computer Engineering Department

CS 1316 Exam 1 Summer 2009

Midterm Exam 2 CS 455, Fall 2014

Exam Duration: 2hrs and 30min Software Design

CS 113 PRACTICE FINAL

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

Midterm Exam 2 CS 455, Spring 2015

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

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

Give one example where you might wish to use a three dimensional array

Introduction to Programming (CS112): Sample

AP Computer Science A (Java) Scope and Sequence

Prelim One Solution. CS211 Fall Name. NetID

CSE 11 Midterm Fall 2008

1.00 Lecture 13. Inheritance

AP CS Unit 7: Interfaces Exercises 1. Select the TRUE statement(s).

COP 3330 Final Exam Review

EXAMINATION INSTRUCTIONS

Faculty of Science FINAL EXAMINATION

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

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

CS 116 Week 8 Page 1

CS 113 MIDTERM EXAM 2 SPRING 2013

Computer Science 1 Ah

Csci 102: Sample Exam

About this sample exam:

Final Exam. COMP Summer I June 26, points

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

Class, Variable, Constructor, Object, Method Questions

EXAMINATION INSTRUCTIONS

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

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

1.00/1.001 Introduction to Computers and Engineering Problem Solving. Final Exam

Lecture 5: Methods CS2301

Instructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII.

Inheritance and Interfaces

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

Final Exam COMP Fall 2004 Dec 16, 2004

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods.

I. True/False: (2 points each)

CS2 Algorithms and Data Structures Note 9

CS 112 Programming 2. Lecture 10. Abstract Classes & Interfaces (1) Chapter 13 Abstract Classes and Interfaces

Questions Answer Key Questions Answer Key Questions Answer Key

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

Advanced Programming - JAVA Lecture 4 OOP Concepts in JAVA PART II

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

Abstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes.

REVIEW EXERCISES. Draw an inheritance diagram that shows the relationships between these classes.

Practice Midterm 1. Problem Points Score TOTAL 50

Inheritance and Interfaces

CONCORDIA UNIVERSITY Summer 2005 Comp 248 /1 Section AA Introduction to Programming Final Examination/A

AP CS Unit 7: Interfaces Exercises Assume all code compiles unless otherwise suggested.

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

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

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

AP CS Unit 6: Inheritance Notes

CS 455 Final Exam Fall 2015 [Bono] Dec. 15, 2015

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

CMPT-166: Sample Final Exam Answer Key

Object-oriented Programming and Software Engineering CITS1001. Multiple-choice Mid-semester Test

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. CMPUT 102: Inheritance Dr. Osmar R. Zaïane. University of Alberta 4

University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ June Exam

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. Inheritance Hierarchy. The Idea Behind Inheritance

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

CSE 131 Introduction to Computer Science Fall Exam II

CS 215 Software Design Sample midterm solutions

COMP-202: Foundations of Programming. Lecture 26: Review; Wrap-Up Jackie Cheung, Winter 2016

McGill University School of Computer Science COMP-202A Introduction to Computing 1

COS 126 Midterm 1 Written Exam Fall 2011

CS 101 Spring 2007 Midterm 2 Name: ID:

CMSC 331 Second Midterm Exam

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

COS 126 General Computer Science Fall Exam 1

Week 4, Wednesday (Spring 2015). Dr. Yoder. Sec 051. Page 1 of 5

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

Object- Oriented Analysis, Design and Programming

Logistics. Final Exam on Friday at 3pm in CHEM 102

York University. AP/ITEC Section M INTRODUCTION TO DATA STRUCTURES Winter Midterm Test

CSE 143, Winter 2009 Final Exam Thursday, March 19, 2009

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

CS 455 Midterm Exam 1 Fall 2013 [Bono] Wednesday, Oct. 2, 2013

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

CS170 Introduction to Computer Science Midterm 2

Generic types. Announcements. Raw ArrayLists. Generic types (cont.) Creating a raw ArrayList: Accessing a raw ArrayList:

Closed book but one sheet, both sides, of A4 paper is allowed. Section 2.5 of the text Generics in the Java Programming Languages by Gilad Bracha

Computer Science 1 Ah

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

York University AK/ITEC OBJECT-BASED PROGRAMMING. Midterm Test Sample. Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes

F I N A L E X A M I N A T I O N

CS 112 Midterm Exam Fall 2016

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

COS 126 General Computer Science Spring Written Exam 1

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

Transcription:

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, Boolean Logic (pp. 2-3) 14 pts Part II: Writing Methods (pp. 4-8) 22 pts Part III: Linear and Binary Search (p. 9) 8 pts Part IV: Inheritance and Dynamic Binding (pp. 10-11) 5 pts

Part I Basic Concepts and Boolean Logic (14 points total) 1. Match each programming concept on the left with the appropriate description on the right. (6 points) class a) descriptions not provided in practice exam interface b) abstract class c) class documentation d) access identifier e) instance variable f) class variable g) local variable h) scope i) constructor j) method k) method signature l) method invocation m) parameter type n) formal parameter o) actual parameter p) return type q) inheritance r) subclass s) superclass t) dynamic binding u) responsibility v) collaboration w) linear (sequential) search x) binary search y) aggregation z) recursion aa) 2

2. Circle all of the code fragments below that are logically equivalent to the following statement: (6 pts) for ( i = 10; i > 0; i-- ) a) i = 10; while ( i > 0 ) i--; } c) i = 11; do i--; } while ( i > 0 ); e) i = 0; while ( i < 10 ) i--; } b) for ( i=1; i < 11; i++ ) d) for ( i=0; i < 10; i++ ) f) for ( i=0; i < 20; i+=2 ) 3. Are the following two code segments logically equivalent? Explain your answer. (2 points) if ( i > 0 ) if ( i > 0 ) return false; return false; else if ( j <= i ) if ( j <= i ) return false; return false; else return true; return true; 3

Part II Write Methods (22 points total) 4. Write a method, isreverse, that takes two ArrayList parameters, x and y, and returns true if the values in y are the same as those in x, except in the opposite order. That is, isreverse should return true if the two lists have the same number of elements and the first element of x is the last element of y, the second element of x is the second to last element of y, and so on. The method should return false otherwise. (4 Pts) public boolean isreverse(arraylist<string> x, ArrayList<String> y) 4

5. The standard Java java.util.gregoriancalendar class has a method that determines whether or not a given year is a leap year. public boolean isleapyear(int year) Write a driver that tests this method. Note that any year that is divisible by 4 is a leap year except those years that are divisible by 100 but not by 400 (for example, 1900 is not a leap year but 2000 is a leap year). Explain why you included each test case. (4 Pts) import java.util.gregoriancalendar; public class MyDriverClass public static void main(string[] args) GregorianCalendar cal = new GregorianCalendar(); System.out.println( Year: Expected Actual ); System.out.println( 2003: false + cal.isleapyear(2003)); 5

Questions 6-8 refer to the Date,Flight, and Airport classes provided on the supplemental sheet. You may assume that all methods you are not writing have been implemented correctly. 6. Implement the Flight method late, which returns true if the flight has arrived (the actual time is initialized) and the actual arrival time is later than the estimated arrival time. Thel a t e method also returns true if the flight has not arrived, but the current time is later than the estimated arrival time. In all other cases late returns false. Note that you can get the current date and time by constructing a new Date object. (4 pts) public class Flight public boolean late() 6

7. Implement the Airport method nbrlateflights, which returns the number of the specified airline s flights that are late today. (5 pts) public class Airport public int nbrlateflights (String airline) 7

8. Implement the Airport method mostlateflights, which returns the name of the airline with the most late flights today. (5 pts) public class Airport public String mostlateflights() 8

Part III Sequential and Binary Search (8 points total) 9. We have discussed linear and binary search techniques. Consider an array, A, containing the following 16 elements: index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 value 11 13 25 26 29 30 31 32 43 44 47 55 59 60 62 73 a) How many elements must we examine to determine whether the value 30 is in array A using a linear search? (1 pt) 1 2 3 4 5 6 b) How many elements must we examine to determine whether the value 30 is in array A using a binary search? (1 pt) 1 2 3 4 5 6 c) How many elements must we examine to determine whether the value 11 is in array A using a linear search? (1 pt) 1 2 3 4 5 6 d) How many elements must we examine to determine whether the value 11 is in array A using a binary search? (1 pt) 1 2 3 4 5 6 10. Suppose we define a structure, called a linked list, which can store all of the same types of information that an array can. The only way to access the elements in a linked list is to start at the beginning of the list and step through all the items in it. (We say a linked list does not have random access because you cannot access the i th element directly; you have to start at the beginning and step through until you get to the i th element.) Pictorially, a linked list may look like the following: Start: 11 -> 13 -> 25 -> 26 -> 29 -> 30 -> For each of the following types of data, would a linear or binary search be the better choice? (4 pts) a) an array of sorted data: b) an array of unsorted data: c) a linked list of sorted data: d) a linked list of unsorted data: 9

Part IV Inheritance and Dynamic Binding (5 points total) 11. What inheritance relationships would you establish among the following classes? Student Professor TeachingAssistant DepartmentChair Person Course Seminar Lecture ComputerLab Draw pictures (they could look like trees or like object diagrams) of the various classes and the inheritance relationships. Label the lines showing the relationships to make it clear the type and direction of the relationships. Do not try to indicate all the other relationships that might exist among the classes. (5 pts) 10