1. ____ is the process of creating a new, derived class from a base class.
A) Accessibility
B) Encapsulation
C) Inheritance
D) Polymorphism
2. A method can be used more than once within a program or in other programs.
A) True
B) False
3. 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
4. You can write as many constructors for a class as you want, as long as they all have different ____ lists.
A) object
B) data field
C) method
D) parameter
1. The ability to use methods without knowing the details of their contents is a feature of ____.
A) abstraction
B) encapsulation
C) inheritance
D) construction
2. A method is a program module that contains a series of statements that carry out a task.
A) True
B) False
3. ____ variables and constants are those that are known to an entire class.
A) Global
B) Local
C) Universal
D) Comprehensive
4. 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
ELSE
IF Average >= 80 or Average <=89 THEN
Output “Nice work”
Output “Your average is: “, Average
ELSE
Output : “Your Average is:”, Average
Output “, You will do better next time!”
ENDIF
1. 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 end catch statement, and a return statement.
A) True
B) False
2. An object is a category of things.
A) True
B) False
3. Simple non-array variables are usually passed to methods by ____.
A) value
B) reference
C) type
D) class
4. When a main() method needs to use another method, it calls, or invokes it.
A) True
B) False
1. A(n) ____ statement indicates the end of the catch block in the pseudo code.
A) final catch
B) finally
C) end catch
D) stop
2. Libraries are collections of classes that serve related purposes.
A) True
B) False
3. 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.
Answer:
int divide(int num, int denom)
{ double reuslt;
try{ return result=num/denom; }
catch(ArithmaticException) {//print Divide by zero}}
4. A (n) ____ is one instance of a class.
A) method
B) object
C) instantiation
D) attribute
- 10 years ago
Purchase the answer to view it
- 1solutions.doc