Question: True/False Indicate whether the statement is true or false. ____ 1. It is conventional, but not required, to begin object names with a lowercase letter
True/False Indicate whether the statement is true or false. ____ 1. It is conventional, but not required, to begin object names with a lowercase letter and to begin class names with an uppercase letter.
____ 2. The modulus operator gives the remainder of integer division; it can be used only with integers.
____ 3. When you use the += operator, you may insert a space between the + and the =.
____ 4. You must always surround a single statement after an if with curly braces.
____ 5. An else must always be associated with an if, and vice versa.
____ 6. Statements that can never execute are called dead code.
____ 7. You may use the this pointer instead of the class name and scope resolution operator when a local variable and a field name conflict.
____ 8. The value of a static field cannot be changed.
____ 9. All constructors are public.
____ 10. The ones complement operator is also called the bitwise complement operator.
Multiple Choice Identify the choice that best completes the statement or answers the question.
11. ___ variables store whole numbers. a. Integer c. Floating point b. Numeric d. Character 12. ____ is a programming language that supports object-oriented techniques. a. COBOL c. BASIC b. C++ d. FORTRAN
13. When you compile a C++ program, error messages and/or ____ might appear. a. bugs c. inconsistencies b. exceptions d. warnings
14. C++ provides ____ simple arithmetic operators for creating arithmetic expressions. a. three c. five b. four d. six
15. A(n) ____ is a digit added to a number (either at the end or at the beginning) that validates the authenticity of the number. a. checksum c. error detection code b. check digit d. CRC
16. When an expression includes a(n) ____ operator, the mathematical operation takes place after the expression is evaluated. a. prefix c. unary b. postfix d. binary
17. The Boolean expression used in an if statement is often a comparison, such as x greater than y, but in C++ it can also be a number or a(n) ____. a. arithmetic expression c. character b. logical expression d. relational expression
18. The _a___ takes one action when its Boolean expression is evaluated as true, and uses an else clause to define the actions to take when the expression is evaluated as false. a. dual-alternative if c. switch statement b. single-alternative if d. conditional operator 19. It is a common mistake to use = instead of ____. a. || c. == b. && d. !=
20. You can use the address operator (_d___) to examine the memory address of a variable. a. % c. * b. $ d. &
____ 21. Which of the following statements has an error? a. int rent[4] = {250, 375, 460, 600}; b. int rent[] = {250, 375, 460, 600}; c. int rent[4] = {250, 375}; d. int rent[4] = {250, 375, 460, 600, 650};
____ 22. A convenient way to set all array elements to zero is to declare as follows: int rent[20] = ____;. a. 0 c. {0} b. {0..0} d. {}
____ 23. An alternative to parallel arrays is to create ____. a. one-dimensional arrays c. arrays of structure objects b. two-dimensional arrays d. arrays of flag variables
____ 24. The ____ of a variable defines where it can be accessed in a program. a. abstraction c. encapsulation b. scope d. lifetime
____ 25. ____ variables are those that are known to all functions in a program. a. Global c. General b. Local d. Modular
____ 26. A(n) ____ value is a value sent from a subfunction to the function that called it. a. return c. subroutine b. output d. function
____ 27. A(n) ____ is the expression used within the parentheses when you call a function. a. value c. input b. argument d. prototype
____ 28. An argument used in a function call is known as a(n) ____ parameter. a. execution c. formal b. actual d. call
____ 29. The scope resolution operator is ____. a. & c. * b. :: d. ->
____ 30. ____ variables are sometimes called class variables, class fields, or class-wide fields. a. Public c. Constant b. Private d. Static
____ 31. The ____ pointer is automatically supplied every time you call a non-static member function of a class. a. this c. const b. super d. void
____ 32. The variable ____ is an example of a correct use of the this pointer. a. *this.employeeIdNum c. *(this.employeeIdNum) b. (*this).employeeIdNum d. *(this).employeeIdNum
____ 33. getName() is a typical example of a(n) ____ function. a. manager c. inspector b. auxiliary d. predicate
____ 34. A ____ function has the same name as its class. a. constructor c. predicate b. manager d. mutator
____ 35. The ____ directive means that you have reached the end of the block of code that you are defining. a. #define c. #ifdef b. #endif d. #ifndef
Completion Complete each statement. 36. The two categories of shortcut arithmetic operators are ____________________ operators and increment and decrement operators.
37. Each case in a switch statement can be followed by any number of statements to execute. Unlike with the if statement, the statements to be executed do not need to be contained in a block with ____________________.
38. Memory locations beyond an array are ____________________ for the array.
39. To ____________________ means to take precedence over.
40. A(n) ____________________ constructor is one that does not require any arguments.
Matching Match each term with the correct statement below. a. implementation section f. this pointer b. class variable g. interface c. abstract data type h. polymorphism d. pointer-to-member operator i. access modifier e. class
____ 41. category of objects
____ 42. contains the functions of a class
____ 43. field that does not belong to a specific object
____ 44. looks like an arrow
____ 45. allows the same operation to be carried out differently depending on the object
Short Answer 46. Use a logical OR to write a more concise equivalent of the following code:
if(saleAmount >= 300) cout << "Delivery available" << endl; else if(areaCode == LOCAL_CODE) cout << "Delivery available" << endl;
47. Write a program that projects sales goals for a salesperson for the next several years.The user should be prompted for a first years merchandise sales amount and a number of years to project the goals. For the first year, the salespersons goal is the current sales amount. After that, sales are projected to grow at a rate of 8 percent per year. You should use a do-while loop.
48. What happens if a subscript exceeds the size of an array?
49. How is the null character represented in C++?
50. What are some errors typically made by beginning programmers when they declare, call, and write functions?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
