Ryerson University Department of Electrical & Computer Engineering COE618 Midterm Examination February 26, 2013

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

Data abstractions: ADTs Invariants, Abstraction function. Lecture 4: OOP, autumn 2003

Prelim One Solution. CS211 Fall Name. NetID

Practice exam for CMSC131-04, Fall 2017

COE318 Lecture Notes Week 10 (Nov 7, 2011)

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

PASS4TEST IT 인증시험덤프전문사이트

Abstract Classes and Interfaces

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

EINDHOVEN UNIVERSITY OF TECHNOLOGY

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

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Tecniche di Progettazione: Design Patterns

Practice Midterm 1. Problem Points Score TOTAL 50

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

Introduction to Computer Science II (CSI 1101)

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a

public Candy() { ingredients = new ArrayList<String>(); ingredients.add("sugar");

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1

Object Oriented Programming. What is this Object? Using the Object s Slots

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 1, Name: KEY A

Arrays. Eng. Mohammed Abdualal

Midterm Exam CS 251, Intermediate Programming October 8, 2014

Name:... ID:... class A { public A() { System.out.println( "The default constructor of A is invoked"); } }

C22a: Problem Solving using Recursion

CS 113 PRACTICE FINAL

CS 307 Midterm 2 Fall 2010

CS-140 Fall Binghamton University. Methods. Sect. 3.3, 8.2. There s a method in my madness.

CMPSCI 187 Midterm 1 (Feb 17, 2016)

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

Object Oriented Programming 2012/13. Final Exam June 12th, 2013

CS-140 Fall Binghamton University. Methods. Sect. 3.3, 8.2. There s a method in my madness.

CS 113 MIDTERM EXAM 2 SPRING 2013

The Object Class. java.lang.object. Important Methods In Object. Mark Allen Weiss Copyright 2000

Midterm Exam CS 251, Intermediate Programming March 12, 2014

University of Palestine. Mid Exam Total Grade: 100

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)

CS 307 Midterm 2 Fall 2009

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 11, Name: KEY

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED

CIS 110 Introduction to Computer Programming. 7 May 2012 Final Exam

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION

Computer Science 145 Midterm 1 Fall 2016

Object Oriented Programming 2015/16. Final Exam June 28, 2016

Selected Questions from by Nageshwara Rao

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

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

CSIS 10A Practice Final Exam Name:

Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Final Examination


JAVA MOCK TEST JAVA MOCK TEST II

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader

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

Appendix 3. Description: Syntax: Parameters: Return Value: Example: Java - String charat() Method

Inheritance & Abstract Classes Fall 2018 Margaret Reid-Miller

CSC 1051 Algorithms and Data Structures I. Midterm Examination March 2, Name:

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

Midterm Exam CS 251, Intermediate Programming March 6, 2015

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

CSE 331 Midterm Exam 2/13/12

CS 455 Midterm Exam 2 Spring 2017 [Bono] Tuesday, April 4, 2017

Object Oriented Programming 2015/16. Final Exam June 17, 2016

Prototype. Design Pattern. from: Design Patterns (Gamma, Helm, Johnson, and Vlissides) p Justin Hendrix CSPP Winter 2010

Final Exam. COMP Summer I June 26, points

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

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

엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University COPYRIGHTS 2017 EOM, HYEONSANG ALL RIGHTS RESERVED

TOPICS TO COVER:-- Array declaration and use.

The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II Instructor: Dr. Bowen Hui. Tuesday, April 19, 2016

CMSC 331 Second Midterm Exam

BSc. (Hons.) Software Engineering. Examinations for / Semester 2

Introduction to Programming Written Examination

Objects and Serialization

J.43 The length field of an array object makes the length of the array available. J.44 ARRAYS

I. True/False: (2 points each)

Solutions to the 2005 exam

Software Construction

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

Account joeacct = new Account (100, new Account (500)); Account joeacct = new Account (100, new Account (500, null));

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

Summer Session 2004 Prelim I July 12, CUID: NetID:

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

The Object clone() Method

CS 116 Week 8 Page 1

CS170 Introduction to Computer Science Midterm 2

1.00 Introduction to Computers and Engineering Problem Solving. Final Examination - May 19, 2004

CS 101 Spring 2007 Midterm 2 Name: ID:

Chapter 13 Abstract Classes and Interfaces

CPSC 211 Introduction to Software Development

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

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

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

CSC 1051 Algorithms and Data Structures I. Midterm Examination October 6, Name:

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

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

Arrays. Weather Problem Array Declaration Accessing Elements Arrays and for Loops Array length field Quick Array Initialization Array Traversals

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

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

McGill University Faculty of Science School of Computer Science. MIDTERM EXAMINATION - Sample solutions. COMP-250: Introduction to Computer Science

Transcription:

Ryerson University Department of Electrical & Computer Engineering COE618 Midterm Examination February 26, 2013 Name: Student # : Time: 90 minutes Instructions This exam contains 6 questions. Please check your copy to make sure that it contains 8 pages (including this page) before you start. (1) This is a closed-book exam. (2) If in doubt on any question, then you must clearly state your own assumption(s). (3) Answer all of the following questions in the space provided. For marking use only (do not fill) Questions Score Max 1 10 2 10 3 10 4 10 5 20 6 10 Total 70 1

1. (10 marks) Write TRUE or FALSE beside each of the following statements: a) A producer creates new objects of a data abstraction given objects of their type as input. b) An abstraction function must be one-to-one. c) An immutable class must declare all its instance variables to be final. d) An abstraction function captures the designer s intent in choosing a particular representation. d) A change to the concrete representation of a data abstraction always changes the abstract concept that is represented. 2. (10 marks) a) Name two relationships that can exist between two use cases. b) Which UML diagram describes the dynamic behavior of the system? c) Which UML diagram describes the static structure of the system? 2

d) Which UML diagram describes the functionality of the system from the user s point of view. 3. (10 marks) Consider the following code: public class Recursion { public static void main(string[] args) { recurse("world"); public static void recurse(string w) { int l = w.length(); if(l == 1) { System.out.println(w); return; System.out.println(w); String v = w.substring(0, l-1); recurse(v); System.out.println(w); What will be the output if we run the main method of the Recursion class. [Note: The substring(int beginindex, int endindex) method of the String class returns a new string that is a substring of this string. The substring begins at the specified beginindex and extends to the character at index endindex - 1. Thus the length of the substring is endindexbeginindex.] 3

4. (10 marks) Consider the following Java code. The classes E is not a checked exception. 1 public class Main { 2 public static void main(string[] args) { 3 int[] a = {2, 4, 3; 4 try { 5 6 7 if( i == 3 ) throw new E(); 8 int j = a[i]; 9 System.out.println( i + j ); 10 11 catch(e e) { 12 System.out.println("catch of E"); 13 14 catch(arrayindexoutofboundsexception e) { 15 System.out.println("catch of ArrayIndexOutOfBoundsException"); 16 17 finally { 18 System.out.println("inside finally"); 19 20 System.out.println("main ends"); 21 22 4

Indicate the output of this code for the following cases: (a) In Line 5, the statement is int i = 2; (b) In Line 5, the statement is int i = 3; c) In Line 5, the statement is int i = 4; 5

5. (20 marks) Consider the following implementation of the Account class: public class Account implements Cloneable { //OVERVIEW: Account represents a bank account. A typical bank //account has owner s name and balance. // Abstraction function is: // AF(c) = an account A // where A.name = c.name and // A.balance = sum (for all i) of c.transactions[i]; // Rep invariant is // c.name!= null and // sum (for all i) of c.transactions[i] >= 0 private String name; private int[] transactions; public Account(String n, int[] trans) { this.name = n; this.transactions = trans; repok(); public boolean repok() { // EFFECTS: Returns true if the rep invariant holds // for this; otherwise returns false // a) Write your code here 6

public Account clone() throws CloneNotSupportedException { // b) Write your code here a) Fill in the body of the repok() method. b) Override the clone() method so that it returns a deep copy (and not a shallow copy). c) Does Account class expose its rep? Explain. 7

6. (10 marks) Consider the following class definition: public class Item { private int id; private Item next; public Item(int i, Item n) { id = i; next = n; public void setnext(item n) { next = n; public Item getnext() { return next; Write code segments that results in the reference diagram shown below: (squares are Item objects with its two instance variables; a, b and c are Item references) a 5 b 9 c 2 1 8