# 2005S1ExamAnswers - VERSION 1 COMPSCI 101 THE UNIVERSITY OF...

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

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

View Full Document

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

View Full Document
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 FIRST SEMESTER, 2005 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 Examiner to complete: Question Mark 1 – 20 (/40) 21 (/8) 22 (/10) 23 (/12) 24 (/5) 25 (/10) 26 (/10) 27 (/5) 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("1 + 2" + 3) ; (a) 6 (b) 123 (c) 1 + 2 + 3 (d) 1 + 23 (e) 3 + 3 2. What is the output produced by the following code? System.out.println(3 / 2 * 5 % 3); (a) 2 (b) 3 (c) 0 (d) 1 (e) None of the above 3. Which of the following is the correct way to declare a symbolic constant? (a) int final size = 10; (b) final int size = 10; (c) int final SIZE = 10; (d) final int SIZE = 10; (e) int size = 10; VERSION 1 - 3 - COMPSCI 101 Question/Answer Sheet ID........................................ CONTINUED 4. Which one of the identifiers shown below follows the style convention for naming classes? (a) countNumbers (b) Print_Alphabet (c) Spaceinvaders (d) JellyBeans (e) myfirstprogram 5. Which one of the five sections of code below does NOT produce the following output: output: AAAA (a) System.out.print("output: "); for (int i = 1; i < 5; i++) { System.out.print("A"); } (b) System.out.print("output: "); for (int i = 1; i < 5 && i != 0; i++) { System.out.print("A"); } (c) System.out.print("output: "); for (int i = 1; i < 5; ) { i = i + 1; System.out.print("A"); } (d) System.out.print("output: "); for (int i = 1; i < 10; i = i + 2) { System.out.print("A"); } (e) System.out.print("output: "); for (int i = 5; i > 1; i--) { System.out.print("A"); } VERSION 1 - 4 - COMPSCI 101 Question/Answer Sheet ID........................................ CONTINUED 6. Given the methods declared below, which statement would result in the value 10 being printed to the screen?...
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 / 32

2005S1ExamAnswers - VERSION 1 COMPSCI 101 THE UNIVERSITY OF...

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

View Full Document
Ask a homework question - tutors are online