CS 235 Midterm 1

Ace your homework & exams now with Quizwiz!

What typically happens as a consequence of the "nnnnnn" component of...

***exact quiz question in terms of "++iter"*** Given code sample: For (list<Item_type>::iterator iter = a_list.begin(); iter != a_list.end(); ++iter) { //sequence of statements } Answer: The iterator pointer advances to the next element of the list.

What is a C++ concept?

***exact quiz question*** -A C++ concept serves as a constraint by limiting the set of arguments that are accepted as template parameters

What are C++ strings?

***exact quiz question*** -A C++ string is an alias for basic_string<char>

What is TRUE of friend functions?

***exact quiz question*** -A friend function is a non member function with access to the class private and protected data members.

When deciding between a vector and a list, _______________.

***exact quiz question*** -A list is more efficient at removing, inserting at the beginning. -Accessing any given element in a vector is more efficient.

7. What is the difference between const and the preprocessor directive #define?

***exact quiz question*** -As a general rule you should give the compiler preference to the preprocessor.

What is C++ object delegation?

***exact quiz question*** -Delegation allows exposure to some functionality of a pre-existing class, but still control access through your own interface

6. What is TRUE of every switch statement?

***exact quiz question*** -Every case does not need a break statement (but it's a good idea to do so). -The expression used in a switch statement must have an integral or enumerated type. -When a break statement is reached, control jumps to the next line following the switch statement. -It is not required that each case be enclosed in braces.

Software practitioners sometimes object to the term "bugs" because __________________.

***exact quiz question*** -It tends to trivialize potentially serious consequences of program defects

What type of errors probably exist in a significant portion of commercial software?

***exact quiz question*** -Logic errors

43. _______________ is a form of an iterator.

***exact quiz question*** -Quiz question is as follows: The most obvious form of an iterator is...? -Answer: a pointer.

For which type of error are try and catch most appropriate?

***exact quiz question*** -Run-time errors

What is a C++ stream?

***exact quiz question*** -The class istream defines the extraction operator (>>) for primitive data types.

All of the following statements are true of iterators EXCEPT what?

***exact quiz question*** -The iterator end() function returns a pointer to the last element in the container.

What is TRUE of a translation unit?

***exact quiz question*** -Translation units are compiled into object files that are joined together by the linker.

What is the difference between variable scope and lifetime?

***exact quiz question*** -Variable scope is the logical group that prevents name collisions from multiple file includes. -Variable lifetime is the time duration where an object is in a valid state. -(ANSWER) A static local variable has a limited scope but an unlimited lifetime.

What best describes the nnn-nnn relationship? ***is-a relationship

***exact quiz question*** -a jet plane is a plane.

What best describes the nnn-nnn relationship? ***has-a relationship

***exact quiz question*** -a train has a train engine

When deciding between a vector and an array, _______________.

***exact quiz question*** -a vector is more efficient than an array in terms of coding time, but less efficient in execution and memory usage.

What is the Big-O of a vector push_back function if its reserve function creates a new array that is nnnnnn times the size of the current array for an object of class Vector, and copies the contents from the old array into the new array?

***exact quiz question*** -amortized order 1.

4. The preprocessor conditional compilation directives ____________________.

***exact quiz question*** -are evaluated at run time.

Why is a Node typically defined as a struct in the private part of the host class?

***exact quiz question*** -because a struct's data members are public by default.

What is the proper relationship between class List and class Ordered_List?

***exact quiz question*** -class Ordered_List has-a List

A template class typically ___________________________.

***exact quiz question*** -facilitates the same set of operations of a variety of data types.

A private data member is visible ________________________.

***exact quiz question*** -it is visible in the class in which it is declared.

What is the principal advantage of a template class?

***exact quiz question*** -its ability to contain different types of data (determined at compile time).

Inserting at the tail of a single-linked list is _____________.

***exact quiz question*** -less efficient than inserting at the head. Inserting at the head is order(1) and inserting at the tail is order(n).

In what order should catch clauses appear?

***exact quiz question*** -most specific to most general

If one class has two functions with the same name, but that take different arguments, this is an example of ________________.

***exact quiz question*** -overloading

In a class that contains a pointer to a dynamically allocated int, the destructor ______________.

***exact quiz question*** -should invalidate the pointer because the memory pointed to by the pointer must be freed to prevent memory leaks.

What is "regression testing"?

***exact quiz question*** -testing to make sure a change did not have an unintended consequence.

Which of the following CANNOT be overloaded?

***exact quiz question*** -the dot operator.

What happens if an exception is thrown in a program and not caught?

***exact quiz question*** -the program aborts

Which of the following describes testing the smallest testable piece of the software?

***exact quiz question*** -unit testing

The default copy constructor may be used EXCEPT ________________________.

***exact quiz question*** -when a deep copy is required.

1. What order is used in the C++ tool chain?

***exact quiz question*** Preprocessor, compiler, assembler, linker

The "order of complexity" of an algorithm expresses ______________________.

***exact quiz question*** -The limiting behavior of a function when the argument tends towards infinity.

What is the difference between a pointer variable and a reference variable?

***exact quiz question...sort of*** -A pointer variable can be assigned a value at any time. -A reference variable is an alias for an already existing variable. -References cannot be NULL, pointers can.

24. Pick the best statement: For correct program execution, _________________________.

***exact quiz question...sort of*** -If the preconditions are met, the post conditions must be achieved.

What is a C++ functor?

-A functor (or function object) is a C++ class that acts like a function and overloads the operator

3. What is the relationship between a class and an object?

-An object is an instance of a class. The class defines the structure and behavior of all objects of it's type. An object is a collection of data and behaviors that represent a thingy.

5. The main function parameters are ____________________.

-Are taken directly from the command line. -int argc, char* argv[]

What is the order of complexity (Big O) of nnnnnnconsecutive loops of n iterations (not nested)?

-Big O of n

What is the probable order of complexity of nnnnnnnested loops, the outer loop of n iterations and the inner loop of up to nnnnnn iterations that decrease by nnnnnn for each loop?

-Big O of n!

In my class of n students, one has my book and only one of them knows which student it is. I start asking each student, one at a time, about all the other students. If I don't find my book from the first student, I move to the next student and repeat the process. What is the Big O of my algorithm?

-Big O of n^2

What are "use cases"?

-I think these refer to cases in which a particular programming language might be the better option to use. For example, when space becomes a concern, C uses much less space and compiles smaller executable files than C++.

Which of the following is a FALSE statement?

-Impossible to tell.

Code refactoring refers to

-It is restructuring existing code. It's done to improve non functioning attributes of the code without changing its external behavior.

Which of the following is TRUE about multiple inheritance?

-It is where a class inherits from multiple parent or base classes. The constructors of inherited classes are called in the same order in which they were inherited. It's usually not recommended, as it can create ambiguities in a deeper inheritance chart.

Which of the following is TRUE of UML diagrams?

-It stands for Unified Modeling Language, and are very often used in industry. They illustrate relationships between classes and external entities. -A solid diamond indicates a "has-a" relationship. -A white arrow indicates a "is-a" relationship.

2. Which part of the compiler program merges the include files into the source file?

-The linker

What is the Big-O of the following:

-This one is impossible to predict.

Which of the following is NOT a software development model?

-Waterfall, spiral, extreme, and agile are all software development models. Choose whichever one is not one of these.

When describing the Big O of an algorithm, what case(s) are often listed?

-We mostly consider regular loops and nested loops.

Using an iterator named iter, how would the container data be accessed?

-We've used *iter before, meaning give us the the data that iter is pointing to. I assume that's what they want us to say.

Which of the following is TRUE concerning abstract classes and concrete classes?

-an abstract class is meant to be used as a base class. It contains one or more pure virtual functions. -a concrete class is one that inherits from an abstract class and defines all pure virtual functions inherited from the abstract class.

What is the difference between a pointer variable and an array name?

-an array is a name for a block of allocated memory. A pointer variable is pointed to a specific singular location of memory.

What best describes the nnn-nnn relationship?

-impossible to tell, I don't know what other relationship we've talked about. Maybe "uses-a" relationship, such as a stack uses a vector.

How does the compiler generate the address of a variable named x?

-it determines whether the variable type needs to get stored on the stack or the heap, it goes and allocates the address with an appropriate size of memory.

What best describes namespaces?

-namespaces allow for multiple variables to exist with the same name. It allows the following to happen. namespace first { int a; } namespace second { int a; } first::a = 50; second::a = 100;

What are C++ input/output manipulators?

-the less than/greater than sharks??? -They are functions specifically designed to be used in conjunction with the insertion and extraction operators.

What are consequences of calling by reference?

-you can change whatever you call by reference, it is often an unintended consequence.

What is the difference between white box testing and black box testing?

Black box testing is testing the program against requirements while not knowing the internal structure of the code. White box testing is testing while knowing how the code is structured.

When using an ofstream, what happens when the output file name already exists?

It overwrites what was already there.

What is the fundamental flaw with the Waterfall software development model?

people complain that it's too linear. Clients don't know what the requirements are beforehand, and change the requirements causes lots more time and efforts.


Related study sets

Transcultural Module 4.02: Transcultural Nursing Society Standards

View Set

NETWORK+ GUIDE TO NETWORKS CHAPTER 3

View Set

Social Studies Exploration Crossword

View Set

NCLEX 10000 ENDOCRINE AND METABOLIC

View Set