2004S2TestQuestions

2004S2TestQuestions - COMPSCI 101 S2 THE UNIVERSITY OF...

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

COMPSCI 101 S2 THE UNIVERSITY OF AUCKLAND SECOND SEMESTER, 2004 COMPUTER SCIENCE Principles of Programming TEST – Question Sheet (Time allowed: 75 MINUTES) INSTRUCTIONS: • Attempt ALL questions Write all answers in the Answer Sheet provided • Calculators are NOT permitted Multi-choice Questions (60 marks – 2 marks each) For each of the following questions, please write your answer on the answer sheet. Write only the letter corresponding to the answer you have chosen. Write the appropriate letter in CAPITALS, using pen. 1. Choose the variable declaration from the items listed below: (a) int max; (b) a = 3; (c) Math.max(a,b) (d) "Max is " (e) "Max is " + max 2. What output is produced by the following code? int a = 0; int b = 7; a = b; b = a; System.out.println(a + b); Choose the correct output from the list below: (a) 0 (b) 00 (c) 7 (d) 14 (e) 77

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

View Full Document
Question Sheet - Page 2 - COMPSCI 101 S2 3. What output is produced by the following code? int a = 1; double b = 7.5; a = (int)b; b = (double)a; System.out.println(a + b); Choose the correct output from the list below: (a) 2.0 (b) 8.0 (c) 8.5 (d) 14.0 (e) 15.0 4. What output is produced by the following code? System.out.println(21 / 2 * 2.0); Choose the correct output from the list below: (a) 5.0 (b) 5.25 (c) 20.0 (d) 21.0 (e) 22.0 5. What output is produced by the following code? System.out.println(3.0 / 2 * 3); Choose the correct output from the list below: (a) 0.0 (b) 0.5 (c) 4.0 (d) 4.5 (e) 9.0 6. What output is produced by the following code? System.out.println(3.0 * 3 / 2); Choose the correct output from the list below: (a) 0.0 (b) 1.5 (c) 3.0 (d) 4.0 (e) 4.5
Question Sheet - Page 3 - COMPSCI 101 S2 7. What output is produced by the following code? System.out.println("\\\"+\\"); Choose the correct output from the list below: (a) \\\"+\\ (b) \\\\\ (c) \"\" (d) \"+\ (e) The statement contains a syntax error and will not compile, so no output is produced. 8. What output is produced by the following code? System.out.println(23%5); Choose the correct output from the list below: (a) 3 (b) 2 (c) 4 (d) 5 (e) 4.6 9. What output is produced by the following code? System.out.println(5 % 3 + 3 % 5); Choose the correct output from the list below: (a) 2 (b) 1 (c) 5 (d) 0 (e) 3 10. What output is produced by the following code? System.out.println(2.0 + 3 + "1" + 2.0 + 3); Choose the correct output from the list below: (a) 5.015.0 (b) 11.0 (c) 2.0315.0 (d) 5.012.03 (e) 2.0312.03

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

View Full Document
Question Sheet - Page 4 - COMPSCI 101 S2 11. What output is produced by the following code? int i = 4; i += 3; i -= 1; System.out.println(i); Choose the correct output from the list below: (a) 1 (b) 3 (c) 5 (d) 6 (e) The code contains a syntax error and will not compile, so no output is produced.
This is the end of the preview. Sign up to access the rest of the 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 / 14

2004S2TestQuestions - COMPSCI 101 S2 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