CS192 Programming Essentials
1. A(n) ____ is one instance of a class.
2. When a variable is declared within a method, it ceases to exist when the method ends.
3. ____ variables and constants are those that are known to an entire class.
4. The memory location known as the ____ is where the computer stores the list of method locations to which the system must return.
A) method stack
B) location stack
C) call stack
D) store location
5. The ability to use methods without knowing the details of their contents is a feature of ____.
6. A method can be used more than once within a program or in other programs.
7. A method is a program module that contains a series of statements that carry out a task.
8. When illegal division by 0 takes place, an Exception object is not created automatically by the object-oriented language application.
9. A catch block consists of four different elements: the keyword catch, followed by parentheses that contain an exception type and identifier, statements that take action to handle the error condition, an endcatch statement, and a return statement.
10. Unreachable code statements are program statements that only execute if there is an exception.
11. Programmers refer to hidden implementation details as existing in a ____.
A) white box
B) white hole
C) black box
D) black hole
12. A ____ is one that sends an exception object out of a method so it can be handled elsewhere.
A) catch statement
B) throw method
C) catch block
D) throw statement
13. The call stack is where the computer stores the list of exceptions.
14. A method’s ____ consists of the method’s statements.
15. What is one item that must be included in a method’s header if it can receive a parameter?
A) local parameter name
B) global parameter name
C) parameter’s client
D) return data structure
16. Libraries are collections of classes that serve related purposes.
17. What will be the output of the below program? List what will be outputed to the screen and explain your answer.
num SIZE = 10
num numbers[SIZE] = 0,0,0,0,0,0,0,0,0,0
index = 0
while index < SIZE
numbers[index]= index * 10
index = index + 1
output “The Output is: ”
while index > 0
index = index – 1
18. An object is a category of things.
19. Global variables are known to the entire class.
20. A parent class is the same thing as a base class.
21. Everything is an object, and every object is a member of a ____.
22. The object-oriented techniques to manage errors such as dividing a value by 0 comprise the group of methods known as ____.
A) exception handling
B) error handling
C) exception processing
D) error processing
23. A class diagram consists of a ____ divided into three sections.
24. Write a method that will perform the a division operation (divide by) on the numbers passed to it in two variables (numerator, denominator) and outputs the results. Use a try-catch pair to output an error message if the illegal operation of divide by 0 occurs.
25. A constructor may require ____.
26. When a main() method needs to use another method, it calls, or invokes it.
27. Design a class named CustomerRecord that holds a customer number, name, and address. Include methods to set the values for each data field and output the values for each data field. Create the class diagram and write the code (not language specific, ie. psuedocode) that defines the class.
28. A child class contains all the data fields and ____ of its parent.
29. What is the screen output of the following code segment? Explain the reasoning behind your answer.
Test1 = 70
Test2 = 80
Test3 = 84
NumberOfTests = 3
Average = (Test1 + Test2 + Test3) / NumberOfTests
IF Average >= 90 THEN
Output “Great job”
Output “Your average is: ”, Average
IF Average >= 80 or Average <=89 THEN
Output “Nice work”
Output “Your average is: “, Average
Output : “Your Average is:”, Average
Output “, You will do better next time!”
30. When a data field is private, it is said to be ____ to any class other than the one in which it is defined.
31. A ____ reference is an automatically created variable that holds the address of an object and passes it to an instance method whenever the method is called.
32. Class diagrams are a type of ____ diagram.
A) Unified Illustration Language
B) Unified Modeling Language
C) Object-Oriented Modeling Language
D) Unified Pseudocode Language
33. Methods are sometimes called ____.
34. A(n) ____ statement indicates the end of the catch block in the pseudocode.
35. Simple non-array variables are usually passed to methods by ____.
36. Methods can be ____ correctly by providing different parameter lists for methods with the same name.
37. You can write as many constructors for a class as you want, as long as they all have different ____ lists.
B) data field
38. Overloaded methods have the same name and parameter lists.
39. Multiple inheritance is the capability to inherit more than one method from a parent class.
40. When appropriate, specialized ____ classes provide an elegant way for you to handle error situations.
41. An instance method or constructor may be overloaded by providing the same name and ____ argument list.
A) a different
B) the same
C) a larger
D) a smaller
42. A ____ is a segment of code that can handle an exception that might be thrown by the try block that precedes it.
A) catch method
B) throw block
C) catch block
D) throw statement
43. ____ is the process of creating a new, derived class from a base class.
44. Creating multiple methods with the same name, which will act differently and appropriately when used with different types of objects, is known as polymorphism.