CSC-1390 Chapter 1
True
A C++ declaration introduces only an identifier's spelling and specifies its type. A) True B) False
True
A C++ declaration is a definition that also allocates storage for an identifier's value (or function's body etc.). A) True B) False
False
A computer program is a set of instructions intended for only the computer to follow. A) True B) False
False
A program should have a comment on every line. A) True B) False
True
A program's comments should connect the program code to the problem being solved. A) True B) False
assigned a value
An l-value is: A) an expression that can be only be placed on the left of any operator such as +, * , /, etc. B) assigned a value C) can never have a value fetched from it D) is designed for use by a left-handed person
can have a value fetched from it
An r-value is: A) an expression that can be only placed on the right of any operator such as +, *, / etc. B) can never be assigned a value C) can have a value fetched from it D)is designed for use by a right-handed person.
Defined
Before a variable is used in C++, it must be: A) initialized B) defined C) used in some expression D) begin with a capital letter E) contain only letters, digits, and underscores
True
C++ not only supports OOP but also supports other programming styles. A) True B) False
False
C++ uses only /** **/ for comments. A) True B) False
False
If we execute the code fragment in an otherwise complete, correct program: int n = 1; cout << n++ << " " << n++ << " " << n++ << endl; the output is guaranteed to be 1 2 3. A) True B) False
False
If we execute this code in an otherwise correct and complete program: n = 1; n = (n++) + (n++); the value of n is guaranteed to be 3 after the second line executes. A) True B) False
False
In C++ the compiler will infer the type intended for a variable from the context in which the variable occurs. A) True B) False
False
In C++ the variables Alpha, ALPHA and AlphA are the same identifier. A) True B) False
xy_z
In C++ which is a legal identifier? A) 9xyz B) X+yz C) xy_z D) xyz!
False
In C++ you can assign an expression of type double to a variable of type int with no problem. A) True B) False
True
In C++ you can assign an expression of type int to a variable of type double with no problem. A) True B) False
be used as an l-value
In C++, a variable that is defined but not initialized may: A) be used in any way any identifier can be used. B) not be used at all C) be used as an l-value D) be used as an r-value E) have its value fetched prior to assignment.
True
OOP is an acronym that means Object Oriented Programming. A) True B) False
#include "cctype "
The following contain several #include directives that may have problems. Which one has one or more problems? A) #include <iostream> B) #include "MyStream.h" C) #include "cctype "
False
The names x, y, and z are satisfactory variable names for the lengths of the legs and hypotenuse of a triangle. A) True B) False
False
The namespace facility is a tool used that assists in the study of genealogy. A) True B) False
None of the above
The person responsible for the initial development of C++ was: A) Denise Richard B) James Gosling C) Barney Strousdup D) Brian Kernigham E) None of the above
False
The range of values for an int variable is from about 0 to +2 billion. A) True B) False
68.0
The value of the expression 20.0 * (9.0/5) + 32.0 is: A) 68.0 B) 52.0 C) expression has a syntax error so there is no value D) 32.0 E) an incorrect expression, the / should be %
52.0
The value of the expression 20.0 * (9/5) + 32.0 is: A) 68.0 B) 52.0 C) incorrect expression so there is no value D) 32.0 E) incorrect expression , the / should be %
False
To put a character into a cstring constant that causes the output to continue on the next line, insert the escape sequence \t into the string constant. A) True B) False
totalWeight
Which is not a C++ keyword? A) while B) totalWeight C) double D) if
Automatic garbage collection
Which of the following does C++ not support? A) Support for object-oriented programming B) Classes C) Global functions D) Automatic garbage collection E) Traditional programming techniques
int namespace(0);
Which of the following is not a legal definition? (Consider each line to be in a different scope so there is no multiple definition of identifiers.) A) int count = 0, limit = 19; B) int count(0), limit(19); C) int count = 0, limit(19); D) int limit = 19; E) int namespace(0);
real
Which of the following is not built into the C++ language: A) bool B) real C) short D) int E) long
rateOfSpeed
Which of the following is the best choice for an identifier in a program? A) x B) rateOfSpeed C) data D) _abc
aa, bb, cc
Which of the following names might give the human reader difficulty about the data that is stored in them? A) aa, bb, cc B) speed, distance, time C) hypotenuse, leg1, leg2 D) velocity01, velocity02, velocity03 E) principal, interest, payment