• Register

Q. Which of the following is a valid C++ array definition?

The correct answer is: int array[10];

Q. Subscript numbering in C++ always starts at _.

zero

Q. When C++ is working with an operator, it strives to convert the operands to the same type.

TRUE

Q. Subscript numbering in C++ always starts at ___.

zero

Q. Which of the following is not a valid C++ identifier?

my Value

Q. Which of the following is an example of a C++ primitive data type? a. unsigned short int b. long double c. unsigned char d. All of these e. None of these

d. All of these

Q. Every C++ program must contain a __ function.

main

Q. Which of the following is/are valid C++ identifiers? A) June-2010 B) June.2010 C) June_2010 D) 2010June E) Both C and D are valid identifiers, but A and B are not.

C) June_2010

Q. Which of the following is a valid C++ array definition?

The correct answer is: int array[10];

Q. C++ programs have always been portable from one compiler to another. True or False

FALSE

Q. In C++, a function prototype is the function heading without the body of the function.

TRUE

Q. In C++ 11, the ________ key word was introduced to represent the address 0. A) nullptr B) NULL C) weak_ptr D) All of these E) None of these

A

Q. The numeric data types in C++ can be broken into two general categories:

integer and floating point

Q. Besides decimal, two other number systems you might encounter in C++ programs are:

Hexadecimal and Octal

Q. What is the output of the following C++ code? int x = 55; int y = 5; switch (x % 7) { case 0: case 1: y++; case 2: case 3: y = y + 2; case 4: break; case 5: case 6: y = y - 3; } cout << y << endl; a. 2 b. 5 c. 8 d. 10

a

Q. What is the output of the following C++ code? int x = 35; int y = 45; int z; if (x > y) z = x + y; else z = y - x; cout << x << “ “ << y << “ “ << z << endl; a. 35 45 80 b. 35 45 10 c. 35 45 -10 d. 35 45 0

b

Q. What is the output of the following C++ code? count = 1; num = 25; while (count < 25) { num = num - 1; count++; } cout << count << “ “ << num << endl; a. 24 0 b. 24 1 c. 25 0 d. 25 1

d

Q. What is the output of the following C++ code? num = 10; while (num > 10) num = num - 2; cout << num << endl; a. 0 b. 6 c. 8 d. 10

d

Q. What is the output of the following C++ code? int j; for (j = 10; j <= 10; j++) cout << j << “ “; cout << j << endl; a. 10 b. 10 10 c. 10 11 d. 11 11

c

Q. In C++, you can create aliases to a previously defined data type by using the ____ statement. a. typedef b. using c. namespace d. alias

A

Q. Of the following, which is a valid C++ identifier? Select one: a. June1997 b. _employee_number c. ___department d. myExtraLongVariableName e. All of these are valid identifiers.

e. All of these are valid identifiers.

Q. In C++, && has a higher precedence than ||.

TRUE

Q. The one place where C++ allows aggregate operations on arrays is the input and output of C-strings.

TRUE

Q. In C++ terminology, a class object is the same as a class instance.

TRUE

Q. Which of the following struct definitions is correct in C++? a. struct studentType { int ID = 1; }; b. struct studentType { int ID; }; c. int struct studentType { ID; } d. struct studentType { string name; int ID; double gpa; }

struct studentType { int ID; };

Q. To use files in a C++ program you must include the ________ header file. a. file b. iostream c. fstream d. Both A and B e. Both B and C.

fstream

Q. Which of the following is a repetition structure in C++?

do while

Q. Which of the following is a valid C++ statement? Answers: a. typedef int; b. typedef integer; c. typedef int integer; d. typedef integer int;

c

Q. In C++, both ! and != are relational operators.

FALSE

Q. Subscript numbering in C++ always starts at

0

Q. If a C++ arithmetic expression has no parentheses, operators are evaluated from left to right. True or false?

TRUE

Q. The C++ operator ____ is used to create dynamic variables.

new

Q. Every complete C++ Program must have a _____

Function named main

Q. In C++, key words are written in all lowercase letters.

True

Q. In C++, ____ is a reserved word. Answers: a. alias b. typecc c. typedef d. deftype

c

Q. Every C++ program must have a A) cout statement B) function main C) #include statement D) All of the above

B

Q. In C++ the = operator indicates a) equality b) assignment c) subtraction d) negation e) none of these

assignment

Q. In the following C++ statement, what will be executed first according to the order of precedence? result= 6-3*2+7-10/2; A) 6 - 3 B) 3 * 2 C) 2 + 7 D) 7 - 10 E) 10 / 2

B) 3 * 2

Q. This is used to mark the end of a complete C++ programming statement.

Semicolon

Q. When C++ is working with an operator, it strives to convert the operands to the same type. T/F

T

Q. In C++, reserved words are the same as predefined identifiers.

FALSE

Q. In C++, ____ is called the scope resolution operator.

::

Q. C#, C++, C, and Java use the symbol ____ as the logical OR operator.

ll

Q. Which of the following is not a valid C++ identifier?

my Value

Q. Assembly language is referred to as a low-level language because it is close to the C++ language.

FALSE

Q. Which of the following class definitions is correct in C++? a. studentType class { public: void setData(string, double, int); private: string name; }; b. class studentType { public: void setData(string, double, int); private: string name; }; c. class studentType { public: void setData(string, double, int); void print() const; private: string name; double gpa; } d. class studentType { public void setData(string, double, int); private string name; };

class studentType { public: void setData(string, double, int); private: string name; };

Q. In C++, the dot operator has a lower precedence than the dereferencing operator.

F

Q. If p is a pointer variable, the statement p = p + 1; is valid in C++.

TRUE

Q. In order, the three-step process of using a file in a C++ program involves:

Open the file, read/write/save data, close the file

Q. The numeric data types in C++ can be broken into two general categories:

integer and floating point

Q.  Which of the following is an example of a C++ primitive data type? A) unsigned short int B) long double C) unsigned char D) All of these E) None of these

D

Q. Write the necessary preprocessor directive to enable the use of the C++ string class .

#include<string>

Q.  Subscript numbering in C++________. A) can be set at runtime B) can begin with a programmer-defined value C) varies from program to program D) begins with zero E) None of these

D

Q. An individual array element can be processed like any other type of C++ variable.

TRUE

Q. Every C++ program must contain a ____ function.

main

Q. Character constants in C++ are always enclosed in

Single quotation marks

Q. In C++ when a relational expression is false, it has the value ________.

0

Q. In C++, the null character is represented as ____. a. ‘\0‘ b. “\0“ c. ‘0‘ d. “0“

‘\0‘

Q. In C++, ____ is called the address of operator.

& or ampersand

Q. In C++, [] is called the array subscript operator. Answers: a. True b. False

a

Q. A C++ member function that sets or changes the value stored in a member variable is called Answers: an updater. a user. an accessor .a get function. a mutator.

a mutator.

Q. ________ are C++ operators that change their operands by one. a. + and - b. ++ and -- c. binary and unary d. arithmetic and relational e. conditional and relational

b. ++ and --

Q. In C++, namespace is a reserved word. Answers: a. True b. False

a

Q. For every opening brace in a C++ program, there must be a: Select one: a. String literal b. Function c. Variable d. Closing brace e. None of these

d. ( Closing brace)

Q. C++ does not have a built in data type for storing strings of characters.

TRUE

Q.  Which of the following is a valid C++ array definition? A) int array[0]; B) float $payments[10]; C) void numbers[5]; D) int array[10]; E) None of these

D

Q. In C++, the dot is an operator called the ____ operator. The ‘.‘ In cin.get(ch1)

member access

Q. (T/F?) In C++, >> is used as a stream extraction operator and as a right shift operator.

TRUE

Q. C++ programs have always been portable from one compiler to another.

FALSE

Q. Which of the following is an example of a C++ primitive data type?

unsigned short int long double unsigned char All of these

Q. In C++, a function prototype is the function heading without the body of the function.

TRUE

Q. Which of the following does not cause a syntax error to be reported by the C++ compiler? a) mismatched {}‘s b) missing / in a comment c) missing ; at the end of a statement d) extra blank lines

d) extra blank lines

Q. TRUE or FALSE: C++ is a procedural language that is widely used by today‘s programmers.

TRUE

Q. To use an output file in a C++ program you must a. make sure the file already exists. b. open the file. c. create a file stream object that will “point to“ (i.e. reference) the file. d. do all of the above. e. do B and C, but not A.

do B and C, but not A

Q. True/False: When C++ is working with an operator, it strives to convert the operands to the same type. Select one: True False

TRUE

Q. Besides decimal, two other number systems you might encounter in C++ programs are: A) Octal and Fractal B) Hexadecimal and Octal C) Unary and Quaternary D) Base 7 and Base 9 E) None of the above

Answer: B

Q. Which of the following is/are valid C++ identifiers? a) June-2010 b) June 2010 c) June_2010 d) 2010June e) Both c & d are valid identifiers, but a & b are not.

June_2010

Q. What is the output of the following C++ code? int x = 35; int y = 45; int z; if (x > y) z = x + y; else z = y - x; cout « x « “ “ « y « “ “ « z « endl; a. 35 45 80 b. 35 45 10 c. 35 45 -10 d. 35 45 0

b. 35 45 10

Q. What is the output of the following C++ code? int x = 55; int y = 5; switch (x % 7) { case 0: case 1: y++; case 2: case 3: y = y + 2; case 4: break; case 5: case 6: y = y - 3; } cout « y « endl; a. 2 b. 5 c. 8 d. 10

a. 2

Q. What is the output of the following C++ code? count = 1; num = 25; while (count < 25) { num = num - 1; count++; } cout « count « “ “ « num « endl; a. 24 0 b. 24 1 c. 25 0 d. 25 1

d. 25 1

Q. What is the output of the following C++ code? num = 10; while (num > 10) num = num - 2; cout « num « endl; a. 0 b. 6 c. 8 d. 10

d. 10

If you found any kind of mistake, like wrong answers or anything syntactical, Please let us know. It will help us in improving content for you guys.

360 points
8 4 2