COSC 1560 – Computer Programming II
Practice Test #1
1. An abstraction is a _________ model of something
a. detailed
b. general
c. simple
d. complex,
e. None of these
2. True/False: When a programmer creates an abstract data type, he or she can decide what values are acceptable for the data type, as well as what operations may be performed on the data type.
3. Before a structure can be used, it must be
a. allocated
b. declared
c. initialized
d. All of these
e. None of these
4. True/False:
The members of a structure or a union must all be the same data type.
5. A ________ is required after the closing brace of the structure declaration.
a. square bracket
b. period
c. semicolon
d. colon
e. None of these
6. When three different variables of a particular structure type are created, they are said to be separate __________ of the structure type.
7. The dot operator allows you to
a. access existing structure members
b. create new structure members
c. output values of structure members
d. make copies of structure members
e. None of these
8. True/False: Any mathematical operations that can be performed on regular C++ variables can be performed on structure members.
9. The members of a structure can be initialized
a. with an initialization list (if the structure has no member that are string objects)
b. in the struct declaration
c. with a constructor
d. by using any of these (i.e. method a, b, or c)
e. by using either method a or c above
10. A Dimension structure, with members int length and int width, is nested inside a Box structure, which has members char type, string color, and Dimension size. If package is an instance of a Box structure, which of the following statements will display package's length?
11. When a structure is passed ___________ a function, its members are not copied.
a. by reference to
b. by value to
c. into a parameter of
d. as an argument to
e. None of these
12. True/False: A union allows all its members to share the same memory space.
13. True/False: You can define any number of union variables, but each variable can only store and use the value of one of its members at a time.
a. determines and returns the area of a circle
b. receives a Circle structure as a parameter, does something, and returns a Circle
structure
c. operates on a constant reference to a Circle structure
d. receives two Circle structures as parameters and does something
e. None of these
15. A good reason to pass a structure as a constant reference is:
a. to prevent changes to the structure members
b. to ensure changes to the structure members
c. to slow down the function's execution, preventing errors
d. to speed up the function's modification of the structure members
e. None of these
16. Objects are created from abstract data types that encapsulate data and _______ together.
a. constants
b. functions
c. memory addresses
d. variables
e. None of these
17. True/False: Whereas object-oriented programming centers around objects, procedural programming centers around functions.
18. In OOP terminology, an object's member variables are often called its _________, and its member functions are sometimes referred to as its behaviors, or ____________.
a. values, morals
b. data, activities
c. attributes, activities
d. attributes, methods
e. None of these
19. A C++ class is similar to a(n)
a. inline function
b. header file
c. library function
d. structure
e. None of these
20. Which of the following is an instance of a class?
a. a method
b. an object
c. a struct
d. an attribute
e. None of these