2000SCExamQuestions

# Forenames continued question 9 7 marks complete the

• Notes
• UltraLightningCobra8457
• 39

This preview shows page 29 - 37 out of 39 pages.

Forenames: ................................ CONTINUED Question 9 (7 marks) Complete the countNumberOfEvens() method which counts how many entries in a 2 dimensional array of int s are even numbers. An example array definition and a sample call to the method is shown below: int[][] twoDInts = { {4, 7, 8, 22, 45}, {41, 73, 58, 202, 45}, {10, 22, 33, 22, 64} }; System.out.println("Evens: "+countNumberOfEvens(twoDInts)); [For the above example the output is Evens: 9 ] //returns the number of even integer values in the array private int countNumberOfEvens(int[][] theInts){

Subscribe to view the full document.

Question/Answer Sheet - 30 - 415.101ST Surname: ................................ Forenames: ................................ CONTINUED } (7 marks)
Question/Answer Sheet - 31 - 415.101ST Surname: ................................ Forenames: ................................ CONTINUED Question 10 (15 marks) The following very large array of String s is used to store a dictionary of words. String[] dictionary = {"aardvark", "aback", ..., "zucchini", "zygote"}; (a) Write a method to test the spelling of a single word. The method should be passed a String as a parameter and should return true if the String is contained in the dictionary array, and should return false otherwise. You can assume that dictionary is declared as an instance variable in the applet containing this method, and so you can refer to it directly. public boolean wordInDictionary(String word) { } (5 marks) (b) Write a method to test the spelling of a collection of words. The method should be passed a Vector of String s as a parameter, containing all the words which are to have their spelling checked. The method should then return a new Vector which contains all the words in the original Vector that are spelled incorrectly - ie. that are not contained in the dictionary array. You should find the method you wrote for (a) useful. For example, given a Vector of Strings called myDocument, the following segment of code could be used to print out all the incorrectly spelled words: Vector mistakes = getMistakes(myDocument); for (int i = 0; i < mistakes.size(); i++) { System.out.println(mistakes.elementAt(i)); } Complete the getMistakes method below: public Vector getMistakes(Vector allWords) {

Subscribe to view the full document.

Question/Answer Sheet - 32 - 415.101ST Surname: ................................ Forenames: ................................ CONTINUED } (10 marks)
Question/Answer Sheet - 33 - 415.101ST Surname: ................................ Forenames: ................................ CONTINUED Question 11 (5 marks) Answer either (a) or (b) below: (a) Explain why privacy of electronic communications and data has become an important principle of the Internet community, name a technical means of assuring it, and briefly explain its function. OR (b) Name a publicly known case of software failure, briefly identify the cause of the failure in general technical terms, and describe a failure of professional ethics that is involved.

Subscribe to view the full document.

Question/Answer Sheet - 34 - 415.101ST Surname: ................................ Forenames: ................................ CONTINUED (5 marks)
Question/Answer Sheet - 35 - 415.101ST Surname: ................................ Forenames: ................................ CONTINUED Overflow Sheet 1 Write the question number next to your answer. You must ALSO indicate in the allotted space that you have used the overflow sheet.

Subscribe to view the full document.

Question/Answer Sheet - 36 - 415.101ST Surname: ................................ Forenames: ................................
You've reached the end of this preview.
• Summer '12
• Computer Science, Subroutine, ........., Eye class

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern