{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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: 4. What output is produced by the following code? System.out.println(21 / 2 * 2.0); Choose the correct output from the list below: 5. What output is produced by the following code? System.out.println(3.0 / 2 * 3); Choose the correct output from the list below: 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: 8. What output is produced by the following code? System.out.println(23%5); Choose the correct output from the list below: 9. What output is produced by the following code? System.out.println(5 % 3 + 3 % 5); Choose the correct output from the list below: 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:
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}