2011S1ExamQuestions

2011S1ExamQuestions - VERSION 00000001 COMPSCI 101...

Info iconThis preview shows pages 1–4. 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 00000001 COMPSCI 101 CONTINUED THE UNIVERSITY OF AUCKLAND FIRST SEMESTER, 2011 Campus: City COMPUTER SCIENCE Principles of Programming (Time Allowed: TWO hours) Note: The use of calculators is NOT permitted. You should separate the Section A Question Booklet from the Section B Question/Answer Booklet. You may keep the Section A Question Booklet. You must hand in the Section B Question/Answer booklet and the Teleform sheet. Compare the exam version number on the Teleform sheet supplied with the version number above. If they do not match, ask the supervisor for a new sheet. Enter your name and student ID on the Teleform sheet. Your name should be entered left aligned. If your name is longer than the number of boxes provided, truncate it. Answer Section A on the Teleform answer sheet provided. Each question in this section is worth 2 marks. For Section A, use a dark pencil to mark your answers in the answer boxes on the Teleform sheet. Check that the question number on the sheet corresponds to the question number in this question/answer book. Do not cross out answers on the Teleform sheet if you change your mind. You must completely erase one answer before you choose another one. If you spoil your sheet, ask the supervisor for a replacement. There is one correct answer per question. Answer Section B in the space provided in the Section B Question/Answer Booklet. Attempt all questions. Write as clearly as possible. The space provided will generally be sufficient but is not necessarily an indication of the expected length. Extra space is provided at the end of this exam book. VERSION 00000001 - 2 - COMPSCI 101 CONTINUED PLEASE CHECK BEFORE YOU START: Have you entered your name and student ID on the Teleform sheet (letters written in the boxes and corresponding circles filled in) and on the front of the Section B question/answer booklet? 1) What output is produced when the following code is executed? System.out.println("[" + 4 + 4 + 3 * 5 / 2 + "," + 2 + 2 + "]"); (a) [447.5,22] (b) [15.5,22] (c) [447,22] (d) [15.5,4] (e) [15,22] 2) Which of the following outputs could NOT have been produced by the following code? int a = (int) (Math.random() * (4 - 1)); int b = (int) (Math.random() * 4) - 1; System.out.println("a: " + a + " b: " + b); (a) a: 0 b: 2 (b) a: 2 b: -1 (c) a: 0 b: 0 (d) a: -1 b: 2 (e) None of the above VERSION 00000001 - 3 - COMPSCI 101 CONTINUED 3) What output is produced when the following code is executed? int a = 9; int b = 1; int c = a % (a - 1); int d = b % (b + 1); int sum = c + d; System.out.println("sum: " + sum); (a) sum: 10 (b) sum: 2 (c) sum: 9 (d) sum: 1 (e) None of the above 4) What output is produced when the following code is executed?...
View Full Document

Page1 / 30

2011S1ExamQuestions - VERSION 00000001 COMPSCI 101...

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

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