2008S2ExamQuestions

2008S2ExamQuestions - COMPSCI 101 THE UNIVERSITY OF...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COMPSCI 101 THE UNIVERSITY OF AUCKLAND CONTINUED SECOND SEMESTER, 2008 Campus: City COMPUTER SCIENCE Principles of Programming (Time allowed: TWO hours) 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 (/32) Q4 (/7) Q7 (/7) Q10 (/6) Q2 (/11) Q5 (/7) Q8 (/7) Q11 (/7) Q3 (/6) Q6 (/7) Q9 (/3) Total /100 - 2 - COMPSCI 101 Question/Answer Sheet ID: ..................................................................... CONTINUED Question 1 (32 marks) a) What is the output produced by the following code? System.out.println("Min is: " + Math.min(1, Math.min(0, -1))); (2 marks) b) What is the output produced by the following code? int value = 13; System.out.println( ! (6 < value) ); (2 marks) c) What is the output produced by the following code? int i = 5; int numbers = {4, 2, -7, 5, 1, 6, 3}; System.out.println(numbers[i] + numbers[i+1]); (2 marks)- 2 - COMPSCI 101 Question/Answer Sheet ID: ..................................................................... CONTINUED Question 1 (32 marks) a) What is the output produced by the following code? System.out.println("Min is: " + Math.min(1, Math.min(0, -1))); (2 marks) b) What is the output produced by the following code? int value = 13; System.out.println( ! (6 < value) ); (2 marks) c) What is the output produced by the following code? int i = 5; int numbers = {4, 2, -7, 5, 1, 6, 3}; System.out.println(numbers[i] + numbers[i+1]); (2 marks)- 3 - COMPSCI 101 Question/Answer Sheet ID: ..................................................................... CONTINUED d) What is the output produced by the following code? String name = "intuitive"; name = name.substring(2); int position = name.indexOf('i'); System.out.println(name.substring(0, position + 1)); (2 marks ) e) What is the output produced by the following code? double d = 23.7, e = 3.1; System.out.println((int)(Math.round(d - e))); (2 marks) f) Complete the output which is produced by the following code. Point p1 = new Point(4, 6); Point p2 = new Point(3, 5); p1.move(10, 4); p2.translate(10, 4); System.out.println("1: " + p1.x + ", " + p1.y); System.out.println("2: " + p2.x + ", " + p2.y); 1: 2: (2 marks)- 4 - COMPSCI 101 Question/Answer Sheet ID: ..................................................................... CONTINUED g) Complete the output which is produced by the following code. Point p1 = new Point(4, 6); Point p2 = new Point(4, 6); Point p3 = p2; p2 = new Point(p3.x, p3.y); System.out.println("1: " + p1.equals(p2)); System.out.println("2: " + (p2 == p3)); 1: 2: (2 marks) h) What is the output produced by the following code?...
View Full 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 / 28

2008S2ExamQuestions - COMPSCI 101 THE UNIVERSITY OF...

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

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