2004SCExamQuestions - VERSION 1 COMPSCI 101 THE UNIVERSITY...

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

View Full Document Right Arrow Icon
VERSION 1 COMPSCI 101 THE UNIVERSITY OF AUCKLAND CONTINUED SECOND SEMESTER, 2004 Campus: City COMPUTER SCIENCE Principles of Programming (Time Allowed: TWO hours) Surname .............................................................................................. Forenames ........................................................................................... Student ID ........................................................................................... Login name(UPI) ................................................................................ NOTE: Attempt ALL questions Answer the multiple choice questions in section A by circling the correct answer Write the answer to the questions in section B in the space provided No books or calculators are permitted Examiner to complete: Question Mark 1 – 22 . (/44) 23 . (/8) 24 . (/8) 25 . (/8) 26 . (/12) 27 . (/10) 28 . (/10) Total . (/100)
Image of page 1

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

View Full Document Right Arrow Icon
VERSION 1 - 2 - COMPSCI 101 Question/Answer Sheet ID ........................................ CONTINUED SECTION A: MULTIPLE CHOICE QUESTIONS Each question in this section is worth 2 marks. Circle the letter corresponding to your choice. There is only one correct answer for each question. 1. What is the output produced by the following code? System.out.println( 3/2 + 5%2 + "4" + 5%2); (a) 3/25%245%2 (b) 1.5141 (c) 1141 (d) 1145%2 (e) None of the above 2. What is the output produced by the following code when the start() method is invoked? public void start() { int a = 4; int b = modify(a); System.out.print(a); System.out.println(modify(a)); } private int modify(int a) { a = a + 3; return a; }
Image of page 2
VERSION 1 - 3 - COMPSCI 101 Question/Answer Sheet ID ........................................ CONTINUED 3. What is the output produced by the following code when the start() method is invoked? public void start() { Point p = new Point(1,2); int x = 3; int y = 4; objectsAndPrimitives(p, x, y); System.out.println(p + " " + x + " " + y); } private void objectsAndPrimitives(Point p, int x, int y) { p.setLocation(5,6); x = 7; y = 8; } 4. What is the output produced by the following code when the start() method is invoked? private void variablesAndScope(int a, int b, Point p) { a = 5; int y = b + 2; p = new Point(9, 9); p.setLocation(8, 8); } public void start() { int x = 3; int y = 4; Point p = new Point(1, 2); variablesAndScope (x, y, p); System.out.println(x + " " + y + " " + p); }
Image of page 3

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

View Full Document Right Arrow Icon
VERSION 1 - 4 - COMPSCI 101 Question/Answer Sheet ID ........................................ CONTINUED 5. What is the output produced by the following code when the start() method is invoked? public void start() { int x = (int)3.3; int y = 4; double d = 6.8; methodsAndParameters ((int)d, x, y); } private void methodsAndParameters(int x, int y, double d) { System.out.println(x + " " + y + " " + d); } (a) 3 4 6.8 (b) 6 3 4 (c) 3 4 6 (d) 6 3 4.0 (e) None of the above
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern