2007SSTestQuestions

2007SSTestQuestions - 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, 2007 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 28 Question 2 6 Question 3 10 Question 4 5 Question 5 14 Question 6 6 Question 7 6 TOTAL 75
Background image of page 2
Question/Answer Sheet - Page 3 - CompSci 101 SS C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED Question 1 (28 marks) a) What output is produced by the following code? System.out.println(1 + 2 + "3" + 4 + 5); (2 marks) b) What output is produced by the following code? System.out.println("\"" + "\\nn"); (2 marks) c) Consider the following boolean expression: (a && b) || (!a) What values would need to be stored in the boolean variables a and b so that this expression evaluates to false ? a = b = (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? int a = 1; int b = 2; int c = 3; int d = Math.max(Math.min(a, b), Math.min(b, c)); System.out.println(d); (2 marks) e) What output is produced by the following code? System.out.println((1 + 2 * 3) / 4 + 5); (2 marks) f) What output is produced by the following code? int x = 100; int y = x; x = 10; System.out.print(y); String s = "10"; String t = s.substring(0,1); System.out.println(s + t); (2 marks) g) What output is produced by the following code?
Background image of page 4
Question/Answer Sheet - Page 5 - CompSci 101 SS C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED int a = 0; int b = 7; a = b; b = a; System.out.println(a + b); (2 marks) h) What output is produced by the following code? int[] nums = { 1, 2, 3, 4, 5 }; nums[0] = nums[3]; nums[1] = nums[2] + nums[4]; nums[2] = nums.length; nums[ nums[1] - nums[2] ] = 10; System.out.print(nums[0] + " "); System.out.print(nums[1] + " "); System.out.print(nums[2] + " "); System.out.print(nums[3] + " "); System.out.print(nums[4] + " "); (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.

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 / 23

2007SSTestQuestions - 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