2008SSTestQuestions

2008SSTestQuestions - CompSci 101 THE UNIVERSITY OF...

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

View Full Document Right Arrow Icon
CompSci 101 THE UNIVERSITY OF AUCKLAND CONTINUED SUMMER SEMESTER, 2008 Campus: City COMPUTER SCIENCE TEST Principles of Programming (Time allowed: 75 MINUTES) NOTE: Attempt ALL questions Write your answers in the space provided There is space at the back for answers that overflow the allotted space No calculators are permitted Surname: Forenames: Student ID number: Login name:
Background image of page 1

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

View Full DocumentRight Arrow Icon
Question/Answer Sheet - Page 2 - CompSci 101 SS C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED CompSci 101 Test Results Question Marks Out of Question 1 26 Question 2 10 Question 3 10 Question 4 10 Question 5 6 Question 6 7 Question 7 7 Question 8 24 TOTAL 100
Background image of page 2
Question/Answer Sheet - Page 3 - CompSci 101 SS C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED Question 1 (26 marks) a) What output is produced by the following code? System.out.println("nn\nn\nn"); (2 marks) b) The following expression will evaluate to one of THREE different values. What are these THREE possible values? int value = (int)(Math.random()*3) * 3 + 2; (2 marks) c) What would be printed by the following? int x = Math.max(Math.max(4, 5), Math.min(6, 7)); System.out.println(x); (2 marks)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Question/Answer Sheet - Page 4 - CompSci 101 SS C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED d) What output is produced by the following code? String a, b; a = new String("cs101"); b = a; a = b.substring(1,3); System.out.println(a + b); (2 marks) e) What output is produced by the following code? int number = 100; while (number % 2 == 0) { number = number / 2; System.out.println(number); } (2 marks) f) What would be printed by the following? String a = "4"; int x = Integer.parseInt(a); x = 10 + x; System.out.println(x); (2 marks)
Background image of page 4
Question/Answer Sheet - Page 5 - CompSci 101 SS C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED g) What output is produced by the following code? double x; x = 1 / 2; System.out.println(x); (2 marks) h) What output is produced by the following code? int a = 1; int b = 2; int c = 3; a = c; c = b; b = a; System.out.println(a + " " + b + " " + c); (2 marks) i) What would be printed by the following? System.out.println((1 + 2 * 3) / 6); (2 marks)
Background image of page 5

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

View Full DocumentRight Arrow Icon
Question/Answer Sheet - Page 6 - CompSci 101 SS C SURNAME: . ..................................................... FORENAMES: . ..........................................................
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 20

2008SSTestQuestions - CompSci 101 THE UNIVERSITY OF...

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

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