samplefinal1 - York University AK/ITEC 1620 3.0 Section A...

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 – Section A OBJECT-BASED PROGRAMMING Fall 2008 Final Exam 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 One.java contains the following implementation of the One class: public class One { public int data; public One (int data) { } } The file Two.java contains the following implementation of the Two class: public class Two { public One obj; public int data; public Two (One obj, int data) { } } The main method in the file MainClass.java uses the above classes: public class MainClass { public static void main(String[] args) { One x = new One(5); One y = new One(5); Two a = new Two(new One(3), 7); // Part 1 – draw the object diagrams at this time x.data = 1; a.data = y.data; y = x; a.obj = x; x = new One(2); // 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 One and Two 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 One and Two 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 simulate coin tosses and output the number of tosses required to get three “heads” in a row. This program will also output to the screen the “heads” and “tails” that it has simulated tossing. For example, your program may produce output as follows: Example 1: HTHHH 5 Example 2: TTTHTHHTTTTHHH 14 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

samplefinal1 - York University AK/ITEC 1620 3.0 Section A...

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