2002ACExamAnswers

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

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

View Full Document Right Arrow Icon
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())); }
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 26 - CompSci 101 AC SURNAME: . ..................................................... FORENAMES: . ..........................................................
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 / 4

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

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