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

Info icon This 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
Image of page 1

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

View Full Document Right 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 } }
Image of page 2