2007S1ExamQuestions

# 2007S1ExamQuestions - VERSION 18832768-1 COMPSCI 101 THE...

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

VERSION 18832768 - 1 - COMPSCI 101 THE UNIVERSITY OF AUCKLAND FIRST SEMESTER, 2007 Campus: City COMPUTER SCIENCE Principles of Programming (Time Allowed: TWO hours) NOTE: Attempt ALL questions. Answer Section A (Multiple choice Questions) on the scantron answer sheet attached. Answer Section B in the spaces provided in this booklet. Calculators are NOT permitted. Surname: Forenames: Student ID number: Login name: Q1 – Q14 (/35) Q17 (/6) Q20 (/10) Q23 (/4) Q15 (/6) Q18 (/12) Q21 (/10) Q16 (/4) Q19 (/10) Q22 (/3) TOTAL (/100)

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

View Full Document
VERSION 18832768 - 2 - COMPSCI 101 Question and Answer Booklet ID. ......................................... CONTINUED SECTION A MULTIPLE CHOICE QUESTIONS Each question in this section is worth 2.5 marks. There is only one correct answer for each question. Select your preferred alternative on the scantron answer sheet provided . 1. What is the output of the following statement? System.out.println("1" + 2 + 3); (a) 123 (b) 15 (c) 33 (d) 6 (e) none of the above 2. What is the output of the following statement? System.out.println(1 + 2 + "3"); (a) 123 (b) 15 (c) 33 (d) 6 (e) none of the above
VERSION 18832768 - 3 - COMPSCI 101 Question and Answer Booklet ID. ......................................... CONTINUED 3. Consider the following method call: myMethod(6 + 12 / 2, "apple", 1 + "one"); How many parameters are being passed to this method? (a) 2 (b) 3 (c) 4 (d) 5 (e) 6 4. 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 true? (a) a = true; b = false; (b) a = true; b = true; (c) a = false; b = false; (d) a = false; b = true; (e) none of the above

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

View Full Document
VERSION 18832768 - 4 - COMPSCI 101 Question and Answer Booklet ID. ......................................... CONTINUED 5. Which one of the following Graphics method calls will draw a circle which has a radius of 100 pixels and is positioned so that the centre of the circle is at location (400,500), as shown in the diagram? (a) g.drawOval(350,450,200,200); (b) g.drawOval(350,450,50,50); (c) g.drawOval(350,450,100,100); (d) g.drawOval(300,400,100,100); (e) g.drawOval(300,400,200,200); 100 (400, 500)
VERSION 18832768 - 5 - COMPSCI 101 Question and Answer Booklet ID. ......................................... CONTINUED 6. What is the output of the following code? String[] s = new String[3]; s[0] = new String("zero"); s[1] = new String("one"); s[2] = new String("two"); s[0] = s[1]; s[1] = s[2]; s[2] = s[0]; for(int i = 0; i < s.length; i++) { System.out.print(s[i] + " "); } (a) one two one (b) one two zero (c) zero zero zero (d) one two two (e) an exception or error will occur when this code is executed 7. What is the output produced by the following code?

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 28

2007S1ExamQuestions - VERSION 18832768-1 COMPSCI 101 THE...

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

View Full Document
Ask a homework question - tutors are online