C++ Programming Language I

Ace your homework & exams now with Quizwiz!

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? "H" "Hello" "Hello World" "Hello World!"

"Hello"

The assignment operator ________ assigns the value of the expression on its right to the variable on its left. <- -> = #

=

________ helps Internet-based applications perform like desktop applications. Ajax Blogging RSS Mashups

Ajax

What is the name of the values the method call passes to the method for the parameters? Arguments. References. Objects. Values.

Arguments

To execute multiple statements when an if statement's condition is true, enclose those statements in a pair of: Parentheses, ( ). Square Brackets, [ ]. Braces, { }. Angle brackets, < >.

Braces, { }.

The C++11 standard was formerly referred to as ________. Old C++ C++10 C++0x C++09

C++0x

Two adjacent parameters are separated by what symbol? Dot. Comma. Parentheses. Braces.

Comma.

Attributes of a class are also known as: Constructors. Local variables. Data members. Classes.

Data members.

Pseudocode normally does not include: Declarations. Input/output. Algorithms. Control structures.

Declarations.

Which of the following languages is used primarily for scientific and engineering applications? Fortran. COBOL. Pascal. Basic.

Fortran.

Having a loop within a loop is known as: Recursion. Doubling up. Nesting. Stacking.

Nesting.

Which of the following operations has the highest precedence? Postincrement. Multiplication. Addition. Assignment.

Postincrement.

Specifying the order in which statements are to be executed in a computer program is called: An algorithm. Transfer of control. Program control. Pseudocode.

Program control.

Which of the following is true? 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

Some of the new C++11 Standard Library features were derived from corresponding Boost libraries.

Which of the following is the escape character? * \ \n "

\

Which of the following is not a valid C++ identifier? my Value _AAA1 width m_x

my Value

What is the default initial value of a String? " " "default" default None of these.

" "

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!! ". "llo! ". "ello! ". "ello".

"llo!! ".

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 <iostream> #include "iostream" #include <GradeBook.h> #include "GradeBook.h"

#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 .hdr .header .cpp

.h

A default constructor has how many parameters? 0. 1. 2. Variable number.

0.

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.25. 5.5. 5. 8.

8

Which of the following is not an arithmetic operator? + - = %

=

Each of the following is a relational or equality operator except: <= =! == >

=!

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. All of the above. None of the above.

All of the above.

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. All of these.

All of these.

Which of the following data items are arranged from the smallest to the largest in the data hierarchy? Records, characters, fields, bits, files. Bits, files, fields, records, characters. Fields, characters, bits, files, records. Bits, characters, fields, records, files.

Bits, characters, fields, records, files.

Today, virtually all new major operating systems are written in: Objective-C. C or C++. Visual C#. Ada.

C or C++.

The data type bool: Can take on values true and false. Can take on any expression as a value. Can take on values -1, 0 or 1. Can only be used in a selection statement.

Can take on values true and false.

The ________ creates object code and stores it on disk. Interpreter Compiler Preprocessor Loader

Compiler

Which of the following statements is true? Interpreted programs run faster than compiled programs. Compilers translate high-level language programs into machine language programs. Interpreter programs typically use machine language as input. None of these.

Compilers translate high-level language programs into machine language programs.

Which of the following is most closely associated with Moore's Law? Every year or two, the price of computers has approximately doubled. Object-oriented programming uses less memory than previous software-development methodologies. Demand for communications bandwidth is decreasing dramatically each year. Every year or two, the capacities of computers have approximately doubled without any increase in price.

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? Mismatched {}. Missing */ in a comment. Missing ; at the end of a statement. Extra blank lines.

Extra blank lines.

As a rule, it is not necessary to declare variables before use in C++ programs. True False

False

C++ is not case sensitive. True False

False

Which of the following is not a key organization in the open-source community? Apache. SourceForge. Firefox. Eclipse.

Firefox.

Which of the following statements is false? Selected Answer: Object-oriented programming is today's key programming methodology. C++ is standardized worldwide through the International Organization for Standardization. Hardware controls software. In use today are more than a billion general-purpose computers and billions more cell phones, smartphones and handheld devices (such as tablet computers).

Hardware controls software.

Which is the output of the following statements? std::cout << "Hello"; std::cout << "World"; Hello World World Hello Hello World World Hello

Hello World

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. In use today are more than a trillion general-purpose computers and trillions more cellphones, smartphones and other handheld devices.

In use today are more than a trillion general-purpose computers and trillions more cellphones, smartphones and other handheld devices.

Which of the following statements is false? Speaking to your computer is a form of input. Playing a video is an example of output . A multi-core processor implements several processors on a single integrated-circuit chip. Information in the memory unit is persistent-it is retained when the computer's power is turned off.

Information in the memory unit is persistent-it is retained when the computer's power is turned off.

Blocks Must contain exactly three statements. Cannot contain declarations. Is a compound statement. Is represented by placing a semicolon (;) where a statement would normally be.

Is a compound statement.

The conditional operator ( ?:): Is the only ternary operator in C++. Is a unary operator. Associates from left to right. Accepts two operands.

Is the only ternary operator in C++.

Which of the following is true of pseudocode? It is executed by the computer. It helps the programmer "think out" a program It includes declarations and all types of statements. All of these are false.

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: Programming phase. Compiling phase. Linking phase. Executing phase.

Linking phase.

Which of the following is not a goal stated by the creator of C++ for the new C++ standard? Make C++ easier to learn. Improve library building capabilities. Make C++ an open source programming language. Increase compatibility with the C programming language.

Make C++ an open source programming language.

________ models software in terms similar to those that people use to describe real-world objects. Object-oriented programming Object-oriented design Procedural programming None of these

Object-oriented design

Which of the following is not one of the six logical units of a computer? Input unit. Output unit. Central processing unit. Printer.

Printer.

________ involves reworking programs to make them clearer and easier to maintain while preserving their correctness and functionality. Object-oriented programming Refactoring Agile software development LAMP

Refactoring

Which software product release category is "generally feature complete and supposedly bug free, and ready for use by the community?" Alpha. Beta. Release candidate. Continuous beta.

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: Member definition linker. Class implementation connector. Source code resolver. Scope resolution operator.

Scope resolution operator.

What type of member functions allow a client of a class to assign values to private data members? Client member functions. Get member functions. Set member functions. None of these.

Set member functions.

Which statement about the Boost C++ Libraries is false? They are free, open source libraries created by members of the C++ community. Some of the new C++11 Standard Library features were derived from corresponding Boost libraries. Two examples of the Boost libraries are the "regular expression" and "smart pointer" libraries. Smart pointers are used to match specific character patterns in text.

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? Machine languages. Assembly languages. High-Level languages. Spoken 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 Graphical Language The Unified Design Language The Unified Modeling Language None of these

The Unified Modeling Language

The compiler will implicitly create a default constructor if: The class does not contain any data members. The programmer specifically requests that the compiler do so. The class does not define any constructors. The class already defines a default constructor.

The class does not define any constructors. The class already defines a default constructor.

In the UML, the top compartment of the rectangle modeling a class contains: The class's name. The class's attributes. The class's behaviors. All of these.

The class's name

Calling a member function of an object requires which item? The dot operator. Open and close braces. The class name. None of these.

The dot operator.

The linker links: The source code with the object code The object code with the libraries. The executable code with primary memory. The primary memory with the CPU.

The object code with the libraries.

An uninitialized local variable contains: The value last stored in the memory location reserved for that variable. No value. A value of zero. A randomly assigned value.

The value last stored in the memory location reserved for that variable.

End-of-line comments that should be ignored by the compiler are denoted using: Two forward slashes ( // ). Three forward slashes ( /// ). A slash and a star ( /* ). A slash and two stars ( /** ).

Two forward slashes ( // ).

Which language was developed by Microsoft in the early 1990s to simplify the development of Windows applications? Visual C#. Python. Objective-C. Visual Basic.

Visual Basic.

C++ functions other than main are executed: Before main executes. After main completes execution. When they are explicitly called by another function. Never.

When they are explicitly called by another function.

The escape sequence for a newline is: \n \t \r \a

\n

Which of the following will not increment c by 1? c + 1; c++; ++c; c += 1;

c + 1;

Which of the following is a repetition structure? if. if...else. do...while. switch.

do...while.

True or False, A constructor can specify a return type

false

Which of the following is a double-selection statement? if. if...else. do...while. switch.

if...else.

Which of the following statements does not overwrite a preexisting value stored in a memory location? int a; number = 12; y = y + 2; width = length;

int a;

Which of the following is a variable declaration statement? int total; #include <iostream> int main() // first string entered by user

int total;

Which of the following is not a keyword that was added to C++ in the new C++11 standard? nullptr. operator. constexpr. noexcept.

operator.

The std::endl stream manipulator________. inputs a newline. flushes the output buffer. outputs a newline and flushes the output buffer. terminates the program.

outputs a newline and flushes the output buffer.

The ________ object enables a program to read data from the user. std::cout std::cin std::cread std::cget

std::cin

Which of the following statements could potentially change the value of number2? std::cin >> number2; sum = number1 + number2; number1 = number2; std::cout << number2;

std::cin >> number2;

Which of the following statements would display the phrase C++ is fun? std::cout << "Thisis fun\rC++ "; std::cout << '++ is fun'; std::cout << "\"C++ is fun\""; std::cout << C++ is fun;

std::cout << "Thisis fun\rC++ ";

What is wrong with the following while loop? while ( sum <= 1000 ) sum = sum 30; The parentheses should be braces. Braces are required around sum = sum 30;. There should be a semicolon after while ( sum <= 1000 ). sum = sum 30 should be sum = sum + 30 or else the loop may never end.

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; x += 4; x =+ 4; x + 4 = x;

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: 5; y: 3 x: 3; y: -1 x: 3; y: 5 x: 1; y: 2

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 = 5; y = x++; y = ++x; y = x + 1

y = x++;

The modulus operator, % can only be used with decimal numbers. is evaluated after subtraction in the order of precedence. can be used to determine if a number is prime. yields the remainder after integer division.

yields the remainder after integer division.

Which of the following statements is false? The concepts of icons, menus and windows were originally developed by Xerox PARC. Windows is an open source operating system. The software that contains the core components of the operating system is called the kernel. Linux source code is available to the public for examination and modification.

Windows is an open source operating system.

Which of the following is true? Assigning a double value to an int does not lose any data. For fundamental-type variables, list-initialization syntax prevents narrowing conversions that could result in data loss. For fundamental-type variables, list-initialization syntax allows narrowing conversions that could result in data loss. None of these.

For fundamental-type variables, list-initialization syntax prevents narrowing conversions that could result in data loss.

Which of the following is true? The only way to define a constructor in a class is to explicitly define one. If you define any constructors with arguments, the compiler will also define a default constructor. If you define any constructors with arguments, the compiler will not define a default constructor. You cannot explicitly create constructors.

If you define any constructors with arguments, the compiler will not define a default constructor.

Which of the following statements is false? The impressive functions performed by computers involve only the simplest manipulations of 1s and 2s. ASCII is a popular subset of Unicode. Fields are composed of characters or bytes. On some operating systems, a file is viewed simply as a sequence of bytes.

The impressive functions performed by computers involve only the simplest manipulations of 1s and 2s.

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: Ensuring that the header of each member function matches its prototype. Ensuring that each member function knows about the class's data members and other member functions. Determining the correct amount of memory to allocate for each object of the class. All of these are uses that the compiler has for the header file information.

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? unsigned int counter = 10; unsigned int counter = { 10 }; unsigned int counter{ 10 }; All of these.

All of these.

Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called: A fatal logic error. A counter exception. A syntax error. An off-by-one error.

An off-by-one error.


Related study sets

▶Chapter 1: Quiz#1 《Lesson 1-Lesson 3 pp. 1-30》Lesson 2

View Set

Chapter 28: Head and Spine Injuries

View Set

Culture et Civilisation Leçons 1-6

View Set

Assignment 15 - The Underwriting Cycle

View Set

Social Psychology Chapter 4, 5 and 6

View Set