• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/40

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

40 Cards in this Set

  • Front
  • Back

Which phase of the software life-cycle is usually the most expensive?

Maintenance and evolution

What will happen if a function is executed and the precondition for the function is not met?

Any of the above results could happen.

What does a run-time analysis usually count?

The number of arithmetic and other operations required for the program to run

What is the common pattern of class definitions that is used in Chapter 2?

Member functions are public, and member variables are private.

Here is a small function definition: void f(int i, int &k) { i = 1; k = 2; } Suppose that a main program has two integer variables x and y, which are given the value 0. Then the main program calls f(x,y); What are the values of x and y after the function f finishes?

x is still 0, but y is now 2.

Which of the following formulas is(are) O(n)

Which of the following formulas is(are) O(n)

d only

When we pretend that we do not know how a function is implemented, we are using a form of information hiding called ___________________________.

functional abstraction

Suppose you write a program that accepts as input any integer in the range –20 through 20, and outputs the number of digits in the input integer. What boundary values should you use as test inputs?

-20, -10, -9, -1, 0, 1, 9, 10, and 20

What are two rules, which are suggested in the textbook, for fully exercising code?

Make sure that each line of your code is executed at least once by some of your test data.Don't allow private data structure to "leak" out of a module.

What statement about "assert" statement in a C++ program is the most accurate?

Assertions can be turned off by placing this statement immediately before the program’s include directives: #define NDEBUG

What boundary values should we use as test inputs for the day variable in the function date_check of ch1 around page 15 of the textbook.

1, 28, 29, 30, and 31

What is the easiest way to turn off all assertion checking in a program?

Put the "#define NDEBUG" before any include directives in the program.

Which of the three forms


a. using namespace main_savitch_2A;


b. using main_savitch_2A::throttle;


c. main_savitch_2A::throttle apollo;


should be used when part of anamespace needs to be used within an actual header file?

c

What are the common patterns for Classes?


a. Public member functions permit programmers to modify and examine objects of the new class.


b. Private member functions permit programmers to modify and examine objects of the new class


.c. Use the keyword const (after the function’s parameter list) when a member function examines data without making modifications.


d. Private member variables of the class store the information about the status of an object of the class.

a, c, and d

Which statement of the following is the most appropriate?

C++ provides many prebuilt classes—the Standard Template Library— for all programmers to use.

A ___________________ is declared by writing the type name followed by the parameter name. With the parameter, the argument provides the initial value for the formal parameter. The parameter is implemented as a local variable of the function, so that any changes made to the parameter in the body of the function will leave the argument unaltered.

default parameter

A ________________________ is declared by writing the type name followed by the character & and the parameter name. With the parameter, any use of that within the body of the function will access the argument from the calling program. Changes made to the formal parameter in the body of the function will alter the argument.

reference parameter

What is an object in C++?

An object refers to a particular instance of a class where the object can be a combination of variables, functions, and data structures.

The following is part of a C++ programming.void throttle::shut_off( )// Precondition: None.// Postcondition: The throttle has been turned off.{ position = 0;}We use the term _________________ to describe a full function definition such as above.

function implementation

What would be one of the common place where the scope resolution operator throttle:: is used.(Ch2 around P42)?

It is used at the head of each member function implementation.

Why is it important to test boundary values when testing programs?

In practice, a large proportion of errors arise from boundary values.

Which of these is used to stop the program execution when a precondition is not met.

assert()

What term is used to describe an O(n) algorithm.

Linear

Here is the start of a class declaration: class foo { public: void x(foo f); void y(const foo f); void z(foo f) const; ... Which of the three member functions can alter the PRIVATE member variables of the foo object that activates the function?

Two of the functions can alter the private member variables of the object that activates the function.

Consider this class definition: class quiz { public: quiz( ); int f( ); int g( ) const; private: double score; }; Which functions can carry out an assignment score=1.0; to the private member variable score?

f can carry out the assignment, but not g.

What statement about "assert(c >= MINIMUM_CELSIUS);" statement in a C++ program is the most accurate?

If the expression (c >= MINIMUM_CELSIUS) is true, then c is valid and the assertion takes no action. On the other hand, if the expression is false, then the precondition has been violated, so a message is printed and the program is halted.

A variable is a declared constant, which means ___________________________________________.

that its value will never be changed while the program is running

Which of the following belong to the Phases of Software Development?a. Specification of the taskb. Design of a solutionc. Implementation (coding) of the solutiond. Analysis of the solutione. Testing and debuggingf. Maintenance and evolution of the systemg. Obsolescence

a, b, c, d, e, f, and g

Which statement of the following is the most appropriate?

One good method for specifying what a function is supposed to do is to provide a precondition and postcondition for the function. These form a contract between the programmer who uses the function and the programmer who writes the function. Using the assert function to check preconditions can significantly reduce debugging time, and the assertion-checking can later be turned off if program speed is a consideration.

What statement about the order of an algorithm is the most accurate?

The order of an algorithm generally is more important than the speed of the processor.

Counting the maximum number of operations is called the ______________________________.

worst-case analysis

One of the libraries is the facility, which contains a function with this prototype:double sqrt(double x);The function returns the square root of x. Which would be a reasonable precondition and postcondition for this function?


Precondition: x is double and greater than zero.Postcondition: The return value is the positive square root of x and also double.

Where would a programmer read to learn how to use a new class?

All the information needed to use the class is in the comment at the front of the header file. So read the comments at the front of header file.

Which statement of the following is the most appropriate?

Object-oriented programming (OOP) supports information hiding by placing data in packages called objects, which are implemented via classes in C++. Objects are manipulated through functions called member functions, which are defined along with their classes.

Please refer to Ch2 throttle class, which of these function calls could change the value of a point p:cout << rotations_needed(p);rotate_to_upper_right(p);

rotate_to_upper_right(p);

Which statement of the following is the most appropriate?

C++ permits you to define the meaning of operators such as + and == for your new classes.

When should a member of a class be declared public?

Member functions.

A _______________________________ may examine the status of an object, but changing the object is forbidden.

constant member function

Suppose a function has a parameter named x, and the body of the function changes the value of x. If we do not want the change affect to the original x, what type of parameter x should we use?

It should be a value parameter.

A modification member function can change the value of an _________________________.

object