2009SSTestQuestions

2009SSTestQuestions - CompSci 101 THE UNIVERSITY OF...

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

View Full Document Right Arrow Icon
CompSci 101 THE UNIVERSITY OF AUCKLAND CONTINUED SUMMER SEMESTER, 2009 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: Q1 (/40) Q3 (/20) Q5 (/10) Q7 (/10) Q2 (/5) Q4 (/10) Q6 (/5) TOTAL (/100)
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 Question 1 (40 marks) a) What output is produced by the following code? String sentence = "I LOVE SUMMER SCHOOL!"; String part = sentence.substring(7, 10); System.out.println(part); (2 marks) b) What output is produced by the following code? String sentence = "Summer school is intensive!"; int index = sentence.indexOf("x"); System.out.println(index); (2 marks) c) What would be printed by the following? String sentence = "Programming is fun!"; System.out.println(sentence.length()); (2 marks)
Background image of page 2
Question/Answer Sheet - Page 3 - CompSci 101 SS C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED d) What output is produced by the following code? String a, b; a = new String("Hello World!"); b = a; System.out.println(a + b.charAt(11)); (2 marks) e) List all possible values that could be generated by the following expression: (int) (Math.random() * 4) + 3 (2 marks) f) What would be printed by the following? System.out.println(Math.min(5, Math.max(3, 7))); (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 g) What output is produced by the following code? System.out.println(2 + 4 + "8" + 9 + (2 + 4)); (2 marks) h) What output is produced by the following code? Assume the user’s input is 23. System.out.println(Keyboard.readInput() + 7); (2 marks) i) What output is produced by the following code? Assume the user’s input is 21. System.out.print(9 + Integer.parseInt(Keyboard.readInput())); (2 marks)
Background image of page 4
Question/Answer Sheet - Page 5 - CompSci 101 SS C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED j) Write a Java boolean expression which tests whether the value of the variable score is outside of the range 3 to 75 (inclusive) but is not equal to 99. (2 marks) k) What is printed by the following?
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
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 / 22

2009SSTestQuestions - CompSci 101 THE UNIVERSITY OF...

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

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