CRC CISP 400 C++ Quiz 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What is the default initial value of a String? 1. "" 2. "default" 3. default 4. None of these.

1. ""

To handle situations where a loop must reinitialize a variable at the beginning of each iteration, such reinitialization could be performed by: 1. A declaration inside the loop body. 2. An assignment statement before the loop body. 3. An assignment statement after the loop body. 4. A declaration after the loop body.

1. A declaration inside the loop body.

A fatal logic error can be caused by: 1. An attempt to divide by zero. 2. Not initializing variables before executing a repetition structure. 3. Using a counter variable in a calculation after the loop. 4. Choosing a sentinel value that is also a data value.

1. An attempt to divide by zero.

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

1. Arguments.

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

1. Braces, { }.

Pseudocode does not include: 1. Declarations. 2. Control structures. 3. Input/output. 4. Algorithms.

1. Declarations.

Which operation does not take place in the following example? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y; 1. Implicit conversion. 2. Promotion. 3. Explicit conversion. 4. Truncation.

1. Implicit conversion.

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

1. Is the only ternary operator in C++.

Which of the following operations has the highest precedence? 1. Postincrement. 2. Multiplication. 3. Addition. 4. Assignment.

1. Postincrement.

Indefinite repetition is controlled by a: 1. Sentinel value. 2. Absence of a condition. 3. Counter. 4. Non-constant condition.

1. Sentinel value.

In indefinite repetition, an input value: 1. Should always be evaluated before being processed. 2. Should never be modified. 3. Can be entered, processed, and evaluated in any order. 4. Should always be processed directly after it is entered.

1. Should always be evaluated before being processed.

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

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

Which of the following will not increment c by 1? 1. c + 1; 2. c++; 3. ++c; 4. c += 1;

1. c + 1;

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

1. if...else.

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

1. x: 1; y: 2.

Assuming that the string object text contains the string "Hello!!!", the expression text.substr( 2 , 5 ) would return a string object containing the string: 1. "ello!". 2. "llo!!". 3. "llo!". 4. "ello".

2. "llo!!".

A solid line representing an association between two classes can be accompanied by any of the following details, except: 1. A number near the end of each line indicating multiplicity values. 2. An aggregation relationship with another association line. 3. A name and direction for the association. 4. A role name for one or both of the objects.

2. An aggregation relationship with another association line.

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: 1. Class implementation connector. 2. Binary scope resolution operator. 3. Member definition linker. 4. Source code resolver.

2. Binary scope resolution operator.

Two adjacent parameters are separated by what symbol? 1. Dot. 2. Comma. 3. Parentheses. 4. Braces.

2. Comma.

In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent? 1. Initial state. 2. Final state. 3. Action state. 4. Transition.

2. Final state.

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!" and then presses Enter? 1. Hello World! 2. Hello 3. H 4. Hello World

2. Hello

Having a loop within a loop is known as: 1. Doubling up. 2. Nesting. 3. A redundancy. 4. Recursive.

2. Nesting.

What type of member functions allow a client of a class to assign values to private data members? 1. Assign member functions. 2. Set member functions. 3. Access member functions. 4. Client member functions.

2. Set member functions.

Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution? 1. y = 5; 2. y = x++; 3. y = ++x; 4. y = x + 1

2. y = x++;

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? 1. #include <iostream> 2. #include "iostream" 3. #include <GradeBook.h> 4. #include "GradeBook.h"

3. #include <GradeBook.h>

A header file is typically given the filename extension: 1. .cpp. 2. .header. 3. .h. 4. .hdr.

3. .h.

A class-type attribute is best modeled by: 1. Breaking the class down into its fundamental-type components. 2. Encapsulating both classes in a third, larger class. 3. A composition association. 4. An inheritance association.

3. A composition association.

An object creation expression contains: 1. The name of the object. 2. The name of the class. 3. All of the above. 4. Parentheses.

3. All of the above.

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

3. An off-by-one error.

A composition or "has-a" relationship is represented in the UML by: 1. Attaching a solid triangle to the association line. 2. Making the association line dashed 3. Attaching a solid diamond to the association line. 4. Making the association line bolded.

3. Attaching a solid diamond to the association line.

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

3. Can take on values true and false.

Multiple parameters are separated by what symbol? 1. Braces. 2. Parentheses. 3. Commas. 4. The dot separator.

3. Commas.

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

3. Data members.

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

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

A block: 1. Must contain exactly three statements. 2. Cannot contain declarations. 3. Is a compound statement. 4. Is represented by placing a semicolon (;) where a statement would normally be.

3. Is a compound statement.

Function headers contain all of the following except: 1. Name of function. 2. Parentheses. 3. Left brace. 4. Return type.

3. Left brace.

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: 1. Programming phase. 2. Compiling phase. 3. Linking phase. 4. Executing phase.

3. Linking phase.

If grade has the value of 60, what will the following code display? If ( grade >= 60 ) cout << "Passed"; 1. nothing. 2. 60 3. Passed 4. cout << "Passed";

3. Passed

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

3. Program control.

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

3. The class does not define any constructors.

Calling a member function of an object requires which item? 1. Open and close braces. 2. None of the above. 3. The dot separator. 4. The class name.

3. The dot separator.

Which of the following does not perform the following task: print correct if answer is equal to 7 and incorrect if answer is not equal to 7? 1. answer == 7 ? cout << "correct" : cout << "incorrect"; 2. If ( answer == 7 ) cout << "correct"; else cout << "incorrect"; 3. cout << answer == 7 ? "correct" : "incorrect"; 4. cout << ( answer == 7 ? "correct" : "incorrect" );

3. cout << answer == 7 ? "correct" : "incorrect";

If x initially contains the value 3, which of the following sets x to 7? 1. x ++ 4;. 2. x =+ 4; 3. x += 4;. 4. x + 4 = x;.

3. x += 4;.

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? 1. #include "iostream". 2. #include . 3. #include "GradeBook.h". 4. #include .

4. #include .

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; 1. 8.25. 2. 5.5. 3. 5. 4. 8.

4. 8.

A constructor can specify the return type: 1. int. 2. string. 3. void. 4. A constructor cannot specify a return type.

4. A constructor cannot specify a return type.

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

4. All of these are uses that the compiler has for the header file information.

Which of the following encompasses the other three? 1. Selection structure. 2. Sequence structure. 3. Repetition structure. 4. Control structure.

4. Control structure.

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

4. Program control.

Which of the following is not a piece of information that could be found in the attribute compartment of a class's rectangle in the UML? 1. The attribute's type. 2. The attribute's name. 3. The attribute's initial value. 4. The attribute's memory location.

4. The attribute's memory location.

All of the following are true about classes, except: 1. An object must be created from a class before it can be used. 2. A class's functions hide from the user the complex tasks they perform. 3. Classes have attributes and behaviors. 4. The first class in any C++ program is main.

4. The first class in any C++ program is main.

Which of the following is true of a pseudocode program? 1. They include declarations and all types of statements. 2. All of the above are false. 3. They are executed by the computer. 4. They help the programmer "think out" a program.

4. They help the programmer "think out" a program.

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

4. When they are explicitly called by another function.

Which of the following is a repetition structure? 1. switch. 2. if...else. 3. if. 4. do...while.

4. do...while.

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

4. sum = sum - 30 should be sum = sum + 30 or else the loop may never end.

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

A. 0.

How many times will the following loop print hello? i = 1; while ( i <= 10 ) cout << "hello"; A. 9. B. An infinite number of times. C. 0. D. 10.

B. An infinite number of times.


संबंधित स्टडी सेट्स

MGMT 309 Final (Ch. 15, 16, 17, 19)

View Set

Unit VI (6) chapter 26 terms (APUSH)

View Set

Post-Lecture Chapter 02 Desc Chem

View Set

Deck Safety - Principles of Stability Questions

View Set

Chapter 42: Nursing Care of the Child With an Alteration in Bowel Elimination/Gastrointestinal Disorder

View Set