spring05finalexa

spring05finalexa - 1.00/1.001 Introduction to Computers and...

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

View Full Document Right Arrow Icon
1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Examination - May 18, 2005 Name: E-mail Address: TA: Section: You have 3 hours to complete this exam. For coding questions, you do not need to include comments, and you should assume that all necessary files have already been imported. Please write legibly. Good luck! Question Points Question 1 /10 Question 2 /30 Question 3 /12 Question 4 /24 Question 5 /24 Total / 100 1 of 16
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 of 16 THIS PAGE INTENTIONALLY LEFT BLANK
Background image of page 2
3 of 16 Question 1. Short answer questions (10 Points) 1) Circle which of the following statements about Hashtables are true. The answers are the same for our lecture implementation or the Java Collections Framework class. a. A Hashtable will keep Objects sorted in the order that they were added. b. You can use an “int” as a key in a Hashtable. c. A Hashtable has slower access to its elements when there are more chains (linked lists). d. A Hashtable has slower access to its elements when each chain (linked list) is longer 2) Which digits, and in what order will be printed when the following program is run? Circle the correct answer. public class MyClass { public static void main(String args[]) { int k = 0; try{ int i = 5/k; } catch (ArithmeticException e1){ System.out.println(“1”); } catch (Exception e2){ System.out.println(“2”); } System.out.println(“3”); } } a. The program will not compile b. The program will print 1 and 2 in that order c. The program will print 1, 2 and 3 in that order d. The program will print 1 and 3 in that order
Background image of page 3

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

View Full DocumentRight Arrow Icon
3) Which of the following statement/s is/are always true? Circle all the correct answers a. Subclasses must define all the methods that the super class defines b. It is possible for a subclass to define a method with the same name and parameters as the super class c. It is possible for a subclass to define a method with the same name but different parameters as the super class d. It is possible for a subclass to inherit from two super classes 4) A thread can be alive, but not running due to which of the following reasons? Circle all the correct answers. a. The run () method of the thread has completed b. The run () method of the thread has not been invoked c. The thread is asleep as a result of invoking its sleep () method d. The thread is not currently the highest priority thread 5) Which of the following is a valid class definition of a class that cannot be instantiated? Circle all the correct answers. a. class MyClass { abstract void MyMethod(); }; b. abstract class MyClass { void MyMethod() {} } c. abstract class MyClass { void MyMethod(); } d. abstract class MyClass { abstract void MyMethod(); } Q1 /10 4 of 16
Background image of page 4
Question 2. Linked list (30 Points) You have a group of points. Each point has an x coordinate, a y coordinate, and a color (either red or blue). The class below represents the points as a linked list. The points are linked via x coordinate and color. The list order is increasing in x, so the point with the smallest x
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 16

spring05finalexa - 1.00/1.001 Introduction to Computers and...

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

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