F01MT1 - CET 230 Applied Data Structures Fall 2001 MidTerm...

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

View Full Document Right Arrow Icon
Applied Data Structures Fall 2001 MidTerm Exam 1 Name: 1. (3 points) What will happen if a method is executed and the precondition for the method is not met? A. An exception will be thrown. B. The program will loop indefinitely. C. The system will crash. D. Any of the above results could happen. 2. (3 points) Answer true or false for this statement: When programming in teams, the specification of a method must be written by the person writing the code for the method. TRUE. FALSE. 3. (3 points) Answer true or false for this statement: When programming individually (not in a team), there is no need to write a specification for a method. TRUE. FALSE. 4. (3 points) If the precondition fails, it is a good idea to throw an exception that will generally halt the program. Why is the program halted? A The Java Runtime System forbids continuation. B. The method is no longer guaranteed to make the postcondition true. C. The method's memory requirements have become exponential (or worse). D. The method's running time has become exponential (or worse). 5. (3 points) Which of these function calls will cause an exception to be thrown when x is 57? (x is an int variable). A. if (0 < x) throw new IllegalArgumentExcpetion("Bad x"); B. if (0 == x) throw new IllegalArgumentExcpetion("Bad x"); C. if (0 > x) throw new IllegalArgumentExcpetion("Bad x"); D. None of the above will cause an exception when x is 42. 6. (3 points) Which of the following statements are valid if ref is a reference variable? A. ref = null; B. if( ref = null ) goBananas(); C. ref = 1944; D. None a thru c are valid. E. All of a thru c are valid. 7. (6 points) When might a class implementer not provide a constructor? Page 1/5
Background image of page 1

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

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

This note was uploaded on 01/02/2012 for the course COMPUTER 101 taught by Professor Dr.kahan during the Spring '11 term at Akademia Ekonomiczna w Krakowie.

Page1 / 5

F01MT1 - CET 230 Applied Data Structures Fall 2001 MidTerm...

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

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