Question: Question 22 In which type of class methods is it typically necessary to filter bad arguments (either directly or indirectly with the help of validators)

Question 22 In which type of class methods is it typically necessary to filter bad arguments (either directly or indirectly with the help of validators) in order to protect private data of your class?

A) A get() method (non-constructor accessor).
B) A default constructor that takes no parameters.
C) A display() (or show()) method, which takes no parameters, intended to output the data of the class for the display.
D) A constructor that takes parameters.
E) A set() method (non-constructor mutator).

Question 23 A linear search algorithm is written (as in the modules, for example) which searches an array for some user-defined value, clientData. If clientData is stored in the array, it returns its array position, and if not found, it returns -1 (again, just like in the modules). Assume the array to be searched has 100 data elements in it. (Check all that apply):

[NOTE: due to common off-by-one interpretations when counting such things, if your predicted answer is within one (+1 or -1) of a posted option below, you can assume your prediction and the choice you are looking at are equivalent and check that option.]

A) It will never require more than 100 comparisons of data before it returns.
B) It might return to the client with an answer after only one comparison of data.
C) It may require as many as 100 comparisons of data before it returns.
D) It will always return with an answer in 10 or fewer comparisons of data.
E) It will always return with an answer in 50 or fewer comparisons of data.

Question 24 A binary search algorithm is written (as in the modules, for example) which searches a pre-sorted array for some user-defined value, clientData. If clientData is stored in the array, it returns its array position, and if not found, it returns -1 (again, just like in the modules). Assume the array to be searched has 100 data elements in it. (Check all that apply):

[NOTE: due to common off-by-one interpretations when counting such things, if your predicted answer is within one (+1 or -1) of a posted option below, you can assume your prediction and the choice you are looking at are equivalent and check that option.]

A) It might return to the client with an answer after only one comparison of data.
B) It may require as many as 99 comparisons of data before it returns.
C) It will always return with an answer in 7 or fewer comparisons of data.
D) It will always return with an answer in 3 or fewer comparisons of data.

Question 25 If an instance method calls another instance method of the same class, an object must be used for dereferencing the call.

A) True
B) False

Question 26 The statements

 Card card1, card2, card3, myCard; card1 = new Card(); card2 = card1; 

will cause how many card objects to be instantiated? (only one correct choice):

A) 4

B) 0
C) 2

D) 3

E) 1

Question 27 How would you create an inner class?

A) Create a class that is derived from a parent class
B) Create a data member of a class that is an object of another class.
C) Start the new class definition before you have reached the closing brace of the previous class definition.

Question 28 Select the derived class constructor definitions that represent actual constructor chaining (never mind the reason or effect, as long as it demonstrates a derived class constructor chaining to a base class constructor). There is more than one correct answer.

 A) Sub() { setDefaults(); super(); // other statements ... } 
 B) Sub() { super(); // other statements ... } 
 C) Sub(int a) { super(); // other statements ... } 
 D) Sub() { Base(); // other statements ... } 
 E) Sub() { super(3); // assumes base constructor takes an int // other statements ... }

Question 29 A program may create many objects/instances of the same class.

A) True
B) False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!