CSE 1302C Final Exam_FA10.docx

advertisement
CSE 1302C Final Exam (The Bacon-ator)
12/14/10
Directions: All answers are to be completed without the assistance of others. You have 90 minutes to
complete the exam. Each question is worth 20%.
Question 0: Imagine you have a 2D array of numbers (ints). Show the code to find the row that sums up
to the largest number. Perhaps it would be best to do this on a secondary sheet of paper.
Question 1: Imagine there is a server called “Hello.com” that has port 1302 open. As part of the
protocol, if you send the word “hello” to the server, it will return the word “hello” in a foreign language
(e.g. “hola”, “aloha”, “bonjour” or “привет”). Show the code to connect to the server, send “hello” to it,
and then print the reply from the server to the screen.
Question 2: Threads allow applications split into multiple paths of execution. Show the code to create
1000 threads that each print out the word “Hello” to the screen.
Question 3: Give an example of how polymorphism was used in one of your projects.
Question 4: Write a program that asks the user for the name of a text file to open. If the file exists, the
program should print out (all of) the contents of the file. If the file doesn’t exist, an exception will be
thrown, and you should print out a message that says “File does not exist”.
Download