2002ACExamAnswers

# 2002ACExamAnswers - Question/Answer Sheet SURNAME Page 25...

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

Question/Answer Sheet - Page 25 - CompSci 101 AC SURNAME: . ..................................................... FORENAMES: . .......................................................... CompSci 101 AC 2002 Final Exam Model Answers QUESTION 1 a) -1 b) 15.105 c) d is: 12.0 d) i is : 123 e) 2 QUESTION 2 private static String randomString(String[] words) { int randIndex = (int)(Math.random() * words.length); return words[randIndex]; } QUESTION 3 private static int[][] flipHorizontal(int[][] a){ int arrayRows = a.length; int arrayCols = a[0].length; int[][] b = new int[arrayRows][arrayCols]; for(int i=0;i<arrayRows; i++){ for(int j=0; j<arrayCols ; j++){ b[i][j] = a[arrayRows-i-1][j]; } } return b; } QUESTION 4 public void actionPerformed(ActionEvent e) { String text = tArea.getText(); String word = tInput.getText(); int index = text.indexOf(word); if (index > -1) tArea.setText(text.substring(0, index+word.length())); }

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

View Full Document
Question/Answer Sheet - Page 26 - CompSci 101 AC SURNAME: . ..................................................... FORENAMES: . ..........................................................
This is the end of the preview. Sign up to access the rest of the 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 / 4

2002ACExamAnswers - Question/Answer Sheet SURNAME Page 25...

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

View Full Document
Ask a homework question - tutors are online