• Register

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

a

Q. ________ are C++ operators that change their operands by one.

++ and --

Q. In C++, class is a reserved word and it defines only a data type. a. True b. False

a. True

Q. If you use a C++ key word as an identifier, your program will: Select one: a. Execute with unpredictable results b. not compile c. understand the difference and run without problems d. Compile, link, but not execute e. None of these

b. not compile

Q. Which of the following is not one of the C++ control structures?

main

Q. A C++ class is similar to one of these

structure

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. In C++, the dot operator has a lower precedence than the dereferencing operator.

FALSE

Q. For every opening brace in a C++ program, there must be a:

Closing brace

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

Subscript numbering in C++ always starts at *zero*.

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

TRUE

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

ANS: T

Q. The C++ ________ operator represents logical AND.

&&

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

a. True

Q. Which of the following is a reserved word in C++?

char

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

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. In C++ 11, the ________ key word was introduced to represent the address 0.

nullptr

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

TRUE

Q. Which of the following does not cause a syntax error to be reported by the C++ compiler?

Extra blank lines.

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

TRUE

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

Q. To use an output file in a C++ program you must

do create a file stream object that will “point to“ (i.e., reference) the file and open the file, but not make sure the file already exists.

Q. Which of the following statements is not valid C++ code?

All of these are invalid (int ptr=&num1; int ptr=int *num1; float num1=*ptr2; )

Q. In order to perform file processing in C++, which header files must be included? a. <cstdio> , <iostream>; and <fstream>. b. <cstdio> and <iostream>. c. <cstdio> and <fstream>. d. <iostream> and <fstream>.

d. <iostream> and <fstream>

Q. The C++ function ____ calculates the largest whole number that is less than or equal to x.

floor(x)

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++, reserved words are the same as predefined identifiers.

FALSE

Q. 1Which of the following statements would display the phrase C++ is fun?

std::cout << “\“C++ is fun\““;

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

::

Q. In C++, ____ is called the address of operator. a. & b. * c. # d. ->

a. &

Q. The following function heading in a C++ program is valid: int funcExp(int u, char v, float g)

TRUE

Q. Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5. n = 1; while (n < 5) { n++; cout << n << “ “; }

TRUE

Q. C++ allows you to redefine the way ________ work when used with class objects. (a) compiler errors (b) preprocessor directives (c) standard operators (d) undefined variables (e) None of these

(c) standard operators

Q. C++ requires that a copy constructor‘s parameter be a(n) ________. (a) integer data type (b) floating point data type (c) pointer variable (d) reference object (e) None of these

(d) reference object

Q. (T/F?) In C++, the dot operator has a lower precedence than the dereferencing operator.

False.

Q. In C++, >> is used as a stream extraction operator and as a right shift operator. Similarly, << is used as a stream insertion operator and as a left shift operator. Both are examples of operator overloading

TRUE

Q. Write a literal representing the false value in C++.

FALSE

Q. In C++, a value can be raised to a power by using ________.

the pow function

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

3 * 2

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. To use an output file in a C++ program you must ________.

create a file stream object that will point to (i.e. reference) the file and open the file, but not make sure the file already exists

Q. In C++, the ____ is called the member access operator. a. . b. , c. :: d. #

a. 

Q. If you use a C++ key word as an identifier, your program will: A) Execute with unpredictable results B) not compile C) understand the difference and run without problems D) Compile, link, but not execute E) None of the above

B

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. In C++, the dot operator has a lower precedence than the dereferencing operator. a. True b. False

b. False

Q. C# supports out-mode parameters, but neither Java nor C++ does. Explain the difference.

Only its designers can answer this question definitely. The advantage of including an out mode for parameter passing is clear: If a parameter is used only to return a value from a subprogram, it is sensible to restrict its use to that. Such a parameter should not be allowed to have an initial value and it must be assigned a value before the subprogram terminates. These restrictions can only be enforced implicitly if a separate mode is included for such parameters. Given the other insecurities of C++, it is not surprising that it does not include an out mode. Java may not include out mode parameters because, at least initially, it was meant to be a simple language.

Q. The programming language C++ evolved from ____.

C

Q. In C++, the phrase “standard output device“ usually refers to:

The display screen

Q. In C++, you declare a pointer variable by using the ____ symbol. a. * b. & c. # d. @

a. *

Q. The range-based for loop, in C++ 11, is designed to work with a built-in variable known as the ________. A) counter variable B) i variable C) iterator D) range variable E) None of these

D

Q. Which of the following statements is not valid C++ code? A) int ptr = &num1; B) int ptr = int *num1; C) float num1 = &ptr2; D) All of these are valid. E) All of these are invalid.

E

Q. This operator is used in C++ to represent equality. A) = B) >< C) !! D) == E) None of these

D

Q. High-level object-oriented programming languages include C++, C#, Java, Dart, and ____.

Python

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.

930 points
6 2