2001SCTestAnswers

2001SCTestAnswers - COMPSCI 101 TEST THE UNIVERSITY OF...

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

View Full Document Right Arrow Icon
COMPSCI 101 TEST CONTINUED THE UNIVERSITY OF AUCKLAND SECOND SEMESTER, 2001 Campus: City/Tamaki COMPUTER SCIENCE TEST SOLUTIONS Principles of Programming (Time allowed: ONE hour and 15 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 Login (UPI) Lab Day and Time Section Marks Out of SECTION A 20 SECTION B 30 SECTION C 10 Total 60
Background image of page 1

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

View Full DocumentRight Arrow Icon
Candidate's Name:___________________ 2 COMPSCI 101 TEST CONTINUED SECTION A 1. Examine each of the following Java statements carefully. For each of the statements, tick the appropriate box to indicate either that the statement is correct, or if it contains any errors, then indicate the category of error (Syntax, Runtime or Logic). If the statement contains an error, then correct the error by writing a correct version of the statement below the original. (Note that there may be more than one way to correct an error - any sensible correction will fine) (a) int i = 34; Correct Syntax Error Runtime Error Logic Error (b) i n ti=3 . 0+5 ; Correct Syntax Error Runtime Error Logic Error i n ti=3+5 ;o r doubl ei=3 . 0+5 ; (c) double customer2345 = 87.754; Correct Syntax Error Runtime Error Logic Error (d)
Background image of page 2
Candidate's Name:___________________ 3 COMPSCI 101 TEST CONTINUED (f) int second = Integer.parseInt("87b"); Correct Syntax Error Runtime Error Logic Error int second = Integer.parseInt("87"); (g) Strings=9 8 ; Correct Syntax Error Runtime Error Logic Error String s = "98"; (h) String u == "hello" + "world"; Correct Syntax Error Runtime Error Logic Error String u = "hello" + "world"; (i) System.out.println(3+4+"is the sum of 3 and 4"); Correct Syntax Error Runtime Error Logic Error (j) System.out.println("(3 + 4)*7="+( 3+4 )*7 ) ; Correct Syntax Error Runtime Error Logic Error (10 marks) Marking Notes (Andrew): S A Syntax error is generated when the code is compiled S A Runtime error means that the code compiles correctly, but error occurs when code is executed S
Background image of page 3

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

View Full DocumentRight Arrow Icon
Candidate's Name:___________________ 4 COMPSCI 101 TEST CONTINUED 2. What is the output of the following application?
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

2001SCTestAnswers - COMPSCI 101 TEST 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