samplefinal2 - York University AK/ITEC 1620 3.0...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
York University AK/ITEC 1620 3.0 OBJECT-BASED PROGRAMMING Final Exam Sample Examiner: S. Chen Duration: Three Hours This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g. for computing and/or communicating) is NOT permitted. Do not unstaple this test book – any detached sheets will be discarded . Answer all questions in the space provided. No additional sheets are permitted. Work independently. The value of each part of each question is indicated. The total value of all questions is 100. Write your name and student number in the space below, and on the top of each sheet of this exam where indicated. NOTE: YOU MAY USE PEN OR PENCIL. Surname: ___________________________________ Given Names: ___________________________________ Student Number: ___________________________________ Total 1 2 3 4 5 6
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Question 1 (15 marks) Object Diagrams: Answer both parts below. The file First.java contains the following implementation of the First class: public class First { public int value; public First (int value) { } } The file Second.java contains the following implementation of the Second class: public class Second { public First first; public int second; public Second (First first, int second) { } } The main method in the file MainClass.java uses the above classes: public class MainClass { public static void main(String[] args) { First x = new First(8); First y = new First(1); Second a = new Second(y, 2); // Part 1 – draw the object diagrams at this time y = x; a.second = a.first.value; x = new First(7); a.first = y; // Part 2 – draw the object diagrams at this time } }
Background image of page 2
Surname:_____________ First name:______________ Student #: _______________ When java MainClass is executed, Part 1 ( 5 marks ): draw the object diagrams for all identifiers of First and Second when the comment line “ // Part 1 – draw the object diagrams at this time ” is reached. Part 2 ( 10 marks ): draw the object diagrams for all identifiers of First and Second when the comment line “ // Part 2 – draw the object diagrams at this time ” is reached.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Structured Programming: Write a program in JAVA that will determine if the input int value represents a valid Wizard Ball score. In Wizard Ball, there are two ways to score – “lightning bolts” which are worth 7 points and “fire balls” which are worth 11 points. To be a valid score, it must be possible to achieve the given score with an integer number of lightning bolts and fire balls. For example, the following inputs would lead to the underlined output: Example 1: 28 valid // four lightning bolts, zero fire balls Example 2: 36 valid // two lightning bolts, two fire balls Example 3: 19 not valid // no possible combinations Example 4: 0 valid // zero lightning bolts, zero fire balls Example 5: 12 not valid // no possible combinations Example 6: 22 valid // zero lightning bolts, two fire balls Please write your program on the following page. You may use this page for rough work, but anything on this page will not be graded
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/06/2010 for the course INFORMATIO ITEC 1620 taught by Professor Stephenchen during the Winter '10 term at York University.

Page1 / 16

samplefinal2 - York University AK/ITEC 1620 3.0...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online