C++ Exam 1
What is the default initial value of a String?
" "
Assuming that text is a variable of type string, what will be the contents of text after the statement cin >> text; is executed if the user types Hello World! then presses Enter?
"Hello"
Assuming that the string object text contains the string "Hello!!! ", the "expression text.substr( 2 , 5 ) would return a string object containing the string:
"llo!! ".
End-of-line comments that should be ignored by the compiler are denoted using:
Two forward slashes ( // ).
Which language was developed by Microsoft in the early 1990s to simplify the development of Windows applications?
Visual Basic
C++ functions other than main are executed:
When they are explicitly called by another function.
Which of the following statements is false?
Windows is an open source operating system
Which of the following is the escape character?
\
What will be the output after the following C++ statements have been executed?
a < b c != d
In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent?
Final state.
Which of the following is not a key organization in the open-source community?
Firefox.
Which of the following is true?
For fundamental-type variables, list-initialization syntax prevents narrowing conversions that could result in data loss.
Which of the following languages is used primarily for scientific and engineering applications?
Fortran
Which of the following statements is false?
Hardware controls software.
Which is the output of the following statements?
Hello World
Which of the following is true?
If you define any constructors with arguments, the compiler will not define a default constructor.
Which of the following statements is false?
Information in the memory unit is persistent-it is retained when the computer's power is turned off.
A block:
Is a compound statement.
The conditional operator (?:):
Is the only ternary operator in C++.
Which of the following is true of pseudocode?
It helps the programmer "think out" a program.
When a client code programmer uses a class whose implementation is in a separate file from its interface, that implementation code is merged with the client's code during the:
Linking phase.
Which of the following is not a goal stated by the creator of C++ for the new C++ standard?
Make C++ an open source programming language.
Which of the following is a compilation error?
Neglecting to declare a local variable in a function before it is used. Using a triple equals sign instead of a double equals sign in the condition of an if statement. Omitting the left and right parentheses for the condition of an if statement. Correct All of these.
Having a loop within a loop is known as:
Nesting.
________ models software in terms similar to those that people use to describe real-world objects.
Object-oriented design
Which of the following statements is false?
Object-oriented programming is today's key programming methodology. C++ is one of today's most popular software development languages. Software commands computer hardware to perform tasks. Correct: In use today are more than a trillion general-purpose computers and trillions more cellphones, smartphones and other handheld devices.
If grade has the value of 60, what will the following code display?
Passed
Which of the following operations has the highest precedence?
Postincrement.
Which of the following is not one of the six logical units of a computer?
Printer.
Specifying the order in which statements are to be executed in a computer program is called:
Program control.
________ involves reworking programs to make them clearer and easier to maintain while preserving their correctness and functionality.
Refactoring
Which software product release category is "generally feature complete and supposedly bug free, and ready for use by the community?"
Release candidate.
In the source-code file containing a class's member function definitions, each member function definition must be tied to the class definition by preceding the member function name with the class name and ::, which is known as the:
Scope resolution operator.
What type of member functions allow a client of a class to assign values to private data members?
Set member functions
Which statement about the Boost C++ Libraries is false?
Smart pointers are used to match specific character patterns in text.
Which of the following is not one of the three general types of computer languages?
Spoken languages.
________ is a graphical language that allows people who design software systems to use an industry standard notation to represent them.
The Unified Modeling Language
The compiler will implicitly create a default constructor if:
The class does not define any constructors
In the UML, the top compartment of the rectangle modeling a class contains:
The class's name.
Calling a member function of an object requires which item?
The dot operator.
Which of the following statements is false?
The impressive functions performed by computers involve only the simplest manipulations of 1s and 2s
The linker links:
The object code with the libraries.
An uninitialized local variable contains:
The value last stored in the memory location reserved for that variable
Which of the following statements could potentially change the value of number2?
std::cin >> number2;
Which of the following is not a syntax error?
std::cout << "Hello world! ";
Which of the following statements would display the phrase C++ is fun?
std::cout << "Thisis fun\rC++ ";
Which of the following code segments prints a single line containing hello there with the words separated by a single space?
std::cout << "hello"; std::cout<< " there";
What is wrong with the following while loop? while ( sum <= 1000 ) sum = sum 30;
sum = sum 30 should be sum = sum + 30 or else the loop may never end.
If x initially contains the value 3, which of the following sets x to 7?
x += 4;
Assuming that x and y are equal to 3 and 2, respectively, after the statement x -= y executes, the values of x and y will be:
x: 1; y: 2
Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution?
y = x++;
The modulus operator, %
yields the remainder after integer division.
A constructor can specify the return type:
A constructor cannot specify a return type.
Assuming that GradeBook.h is found in the current directory and the iostream header file is found in the C++ Standard Library header file directory, which of the following preprocessor directives will fail to find its desired header file?
#include <GradeBook.h>
In what order would the following operators be evaluated Assume that if two operations have the same precedence, the one listed first will be evaluated first.
*, /, %, -, +
A header file is typically given the filename extension:
.h
The escape sequence for a newline is:
/n
A default constructor has how many parameters?
0
What is the value of result after the following C++ statements execute?
119
What is the final value of x after performing the following operations? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y;
8
The assignment operator ________ assigns the value of the expression on its right to the variable on its left.
=
Each of the following is a relational or equality operator except:
=!
________ helps Internet-based applications perform like desktop applications.
Ajax
When compiling a class's source code file (which does not contain a main function), the information in the class's header file is used for all of the following, except:
All of these are uses that the compiler has for the header file information.
Which of the following statements initializes the unsigned int variable counter to 10?
All of these.
How many times will the following loop print hello? i =1; while (i <= 10) cout << "hello";
An infinite number of times.
Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called:
An off-by-one error.
What is the name of the values the method call passes to the method for the parameters?
Arguments
Which of the following data items are arranged from the smallest to the largest in the data hierarchy?
Bits, characters, fields, records, files.
To execute multiple statements when an if statement's condition is true, enclose those statements in a pair of:
Braces, { }.
Today, virtually all new major operating systems are written in:
C or C++.
The C++11 standard was formerly referred to as ________.
C++0x
The data type bool:
Can take on values true and false.
Two adjacent parameters are separated by what symbol?
Comma
The ________ creates object code and stores it on disk.
Compiler
Which of the following statements is true?
Compilers translate high-level language programs into machine language programs.
Which of the following is true?
Correct : Some of the new C++11 Standard Library features were derived from corresponding Boost libraries. None of the new C++11 Standard Library features were derived from corresponding Boost libraries. C++11 does not have any new Standard Library features. None of these
Attributes of a class are also known as:
Data members.
Pseudocode normally does not include:
Declarations
Which of the following is true about C++ Variables?
Every variable stored in the computer's memory has a name, a value, a type and a size. A variable name is any valid identifier that is not a keyword. Correct: All of the above. None of the above.
Which of the following is most closely associated with Moore's Law?
Every year or two, the capacities of computers have approximately doubled without any increase in price.
Which of the following does not cause a syntax error to be reported by the C++ compiler?
Extra blank lines.
As a rule, it is not necessary to declare variables before use in C++ programs.
False
C++ is not case sensitive.
False
Which of the following will not increment c by 1?
c + 1;
Which of the following does not display correct if answer is equal to 7 and incorrect if answer is not equal to 7?
cout << answer == 7 ? "correct" : "incorrect"
Which of the following is a repetition structure?
dowhile.
Which of the following is a double-selection statement?
ifelse.
Which of the following statements does not overwrite a preexisting value stored in a memory location?
int a;
Which of the following is a variable declaration statement?
int total;
Which of the following is not a valid C++ identifier?
my Value
Which of the following is not a keyword that was added to C++ in the new C++11 standard?
operator
The std::endl stream manipulator________.
outputs a newline and flushes the output buffer.
The ________ object enables a program to read data from the user.
std::cin