2004SSTestAnswers

2004SSTestAnswers - SUMMER SEMESTER, 2004 Campus: City...

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

View Full Document Right Arrow Icon
SUMMER SEMESTER, 2004 Campus: City COMPUTER SCIENCE TEST ANSWERS Principles of Programming ANSWERS QUESTION 1 a) 19a b) 5 + 1.5 c) 2 d) ask ball e) 2.0 f) 2.0 g) true h) [1,10] i) 8 j) \n" k) -15 l) 5 m) 11.0 n) 10.15 QUESTION 2 a) The cast is performed before the multiplication, hence the result is always 1 b) There are no curly braces to define the two lines of code in the loop body, hence the loop is infinite. c) The parseInt() method must take a String as a parameter, rather than an int . QUESTION 3 a) 1. result: true 2. result: false 3. result: false 4. b) 1. line 1 line 2 line 7 line 8
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: . .......................................................... 2. line 4 line 6 line 8 QUESTION 4 private static String fillOutString(String s, int numChar){ String str = ""; int len = s.length(); int numToPad = numChar - len; if (numToPad <=0) return s;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

2004SSTestAnswers - SUMMER SEMESTER, 2004 Campus: City...

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

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