Test Series - cpp

Test Number 16/102

Q: The constants are also called as _____________
A. const
B. preprocessor
C. literals
D. variables
Solution: Other name for Constants are literals.
Q: What are the parts of the literal constants?
A. integer numerals
B. floating-point numerals
C. strings and boolean values
D. all of the mentioned
Solution: Because these are the types used to declare variables and so these can be declared as constants.
Q: How are the constants declared?
A. const keyword
B. #define preprocessor
C. both const keyword and #define preprocessor
D. $define
Solution: The const will declare with a specific type value and #define is used to declare user-defined constants.
Q: Which of the following statement is not true about preprocessor directives?
A. These are lines read and processed by the preprocessor
B. They do not produce any code by themselves
C. These must be written on their own line
D. They end with a semicolon
Solution: No terminating character required for preprocessor directives statements.
Q: Regarding the following statement which of the statements is true?

const int a = 100;
A. Declares a variable a with 100 as its initial value
B. Declares a construction a with 100 as its initial value
C. Declares a constant a whose value will be 100
D. Constructs an integer type variable with an as identifier and 100 as the value
Solution: Because the const is used to declare non-changeable values only.
Q: The difference between x and ‘x’ is?
A. The first one refers to a variable whose identifier is x and the second one refers to the character constant x
B. The first one is a character constant x and the second one is the string literal x
C. Both are same
D. Both are string literal
Solution: In a C++ code, names with quotes like ‘x’ represent a character or string(in case of a collection of characters) whereas without quotes they represent an identifier.
Q: How to declare a wide character in the string literal?
A. L prefix
B. l prefix
C. W prefix
D. Z prefix
Solution: It can turn this as the wide character instead of narrow characters.
Q: Which value can we not assign to reference?
A. integer
B. floating
C. unsigned
D. null
Solution: If it can be assigned with a null value means, it is a copy of the pointer.
Q: Identify the incorrect statement.
A. Reference is the alternate name of the object
B. A reference value once defined can be reassigned
C. A reference value once defined cannot be reassigned
D. Reference is the alternate name of the variable
Solution: Reference is a thing which points to the valid memory address, so it can’t be redesigned.
Q: Which reference modifier is used to define the reference variable?
A. &
B. $
C. #
D. @
Solution: & aka ‘ampersand’ used to define a reference variable.

You Have Score    /10