Midterm Solutions (Version 2) Fall 2014

First-page document preview for Midterm Solutions (Version 2) Fall 2014 in COE 318: Software Systems at Toronto Metropolitan University (TMU). Inspect the first page below or request the complete PDF study document for free.

Independent study archive Learn more

Materials are uploaded by users for self-study purposes. PwnHero is an independent platform, not affiliated with, sponsored by, or endorsed by any university or institution.

📄 Page 1 Preview
First page preview of Midterm Solutions (Version 2) Fall 2014 for Software Systems at Toronto Metropolitan University (TMU)

Page 1 Key Topics & Excerpt

🔍 Text Transcript

First page excerpt for quick study reference. Complete formulas, diagrams, and subsequent pages are available in the full document.

PwnHero 1 Ryerson University Department of Electrical & Computer Engineering COE318 Midterm Oct. 15, 2014 Name:________________________ Student number:________ Time: 60 minutes Circle the name of your Professor: E. Bagheri, K. Clowes, O. Das This is a closed-book exam. If in doubt on any question, then you must clearly state your own assumption(s). _____________________________________________________________ Question 1. (5 marks) Here is an incomplete declaration for the Book class. a) Write the code for the constructor of the Book class. b) Write the code for the toString method of the Book class. public class Book { String title; double price; // Constructor // Initializes the instance variables title and price with the // specified arguments public Book(String t, double p) { // (a) Write the constructor code here } // Returns a string containing the title and price of this Book // object. The title and price should be separated by a comma. // For example, for a book whose title is “Java” and price 24.0, // this method should return the string “Java, 24.0” public String toString() { // (b) Write the toString method code here } } PwnHero.com

Related COE Courses at Toronto Metropolitan University (TMU)