2004SCExamQuestions

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

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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) 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; } (a) 47 (b) 77 (c) 710 (d) 44 (e) None of the above 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; } (a) java.awt.Point[x=1,y=2] 3 4 (b) java.awt.Point[x=1,y=2] 7 8 (c) java.awt.Point[x=5,y=6] 3 4 (d) java.awt.Point[x=5,y=6] 7 8 (e) java.awt.Point[x=0,y=0] 0 0 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); } (a) 3 4 java.awt.Point[x=1,y=2] (b) 3 6 java.awt.Point[x=1,y=2] (c) 5 6 java.awt.Point[x=8,y=8] (d) 5 4 java.awt.Point[x=1,y=2] (e) 3 4 java.awt.Point[x=8,y=8] VERSION 1 - 4 - COMPSCI 101 Question/Answer Sheet ID...........................................
View Full Document

This note was uploaded on 03/01/2012 for the course COMPSCI 101 taught by Professor Adrianaferraro during the Summer '12 term at Auckland.

Page1 / 33

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

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