2003FCExamAnswers

2003FCExamAnswers - CompSci 101 S1 C 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 S1 C THE UNIVERSITY OF AUCKLAND CONTINUED First Semester, 2003 City Campus COMPUTER SCIENCE Principles of Programming (Time allowed: TWO HOURS) Surname: Forenames: Student ID number: Login name (UPI): INSTRUCTIONS: Attempt ALL questions - write your answers in the box provided Calculators are NOT permitted Examiner to complete: Question Mark Question Mark 1 (/15) 6 (/10) 2 (/10) 7 (/10) 3 (/5) 8 (/10) 4 (/15) 9 (/10) 5 (/5) 10 (/10) 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 S1 C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED Question 1 (15 marks) a) What type of variable should be used to hold the value listed below? 56.0 double (1 mark) b) What type of variable should be used to hold the value listed below? 'F' char (1 mark) c) What is printed when the following statement is executed? System.out.println( 7%5 ); 2 (1 mark) d) What is printed when the following statement is executed? System.out.println( 12%13 ); 12 (1 mark) e) What is printed when the following statements are executed? int a = 3, b = 4; System.out.println( ++a + " " + b++ ); 4 4 (1 mark)
Background image of page 2
Question/Answer Sheet - Page 3 - CompSci 101 S1 C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED f) What is printed when the following statement is executed? System.out.println( 1+2*3/4 ); 2 (1 mark) g) What is printed when the following statement is executed? System.out.println( 4/3*(2+1) ); 3 (1 mark) h) What is printed when the following statement is executed? System.out.println( (double)1+2/3 ); 1.0 (1 mark) i) What is printed when the following statement is executed? System.out.println( 3/4*1.0 + 1.0*3/4 ); 0.75 (1 mark) j) What is printed when the following statement is executed? System.out.println( 1 + 2 + "3" + 4 + 5 ); 3345 (1 mark)
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 S1 C SURNAME: . ..................................................... FORENAMES: . .......................................................... CONTINUED k) What is printed when the following statements are executed? int a = 4; int b = 5; a = b; b = a; System.out.println( a + " " + b ); 5 5 (1 mark) l) What is printed when the following statement is executed? System.out.println( "1" + "//\\+" + "+//\\" + 2 ); 1//\++//\2 (1 mark) m) What is printed when the following statements are executed? String s = "Hello"; String w = s.substring(2,3); System.out.println( s + " " +w ); Hello l (1 mark) n) What is printed when the following statements are executed? int a = 3; int b = 4; int c = 5; System.out.println( Math.max(a, Math.min(Math.max(a,c), b)) ); 4 (1 mark) o) What is printed when the following statement is executed?
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 / 23

2003FCExamAnswers - CompSci 101 S1 C 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