Test Series - cpp

Test Number 20/102

Q: Which operator is having the right to left associativity in the following?
A. Array subscripting
B. Function call
C. Addition and subtraction
D. Type cast
Solution: There are many rights to left associativity operators in C++, which means they are evaluation is done from right to left. Type Cast is one of them. Here is a link of the associativity of operators: https://github.com/MicrosoftDocs/cpp-docs/blob/master/docs/cpp/cpp-built-in-operators-precedence-and-associativity.md
Q: Which operator is having the highest precedence?
A. postfix
B. unary
C. shift
D. equality
Solution: The operator which is having the highest precedence is postfix and lowest is equality.
Q: What is this operator called ?:?
A. conditional
B. relational
C. casting operator
D. unrelational
Solution: In this operator, if the condition is true means, it will return the first operator, otherwise second operator.
Q: What is the use of dynamic_cast operator?
A. it converts virtual base class to derived class
B. it converts the virtual base object to derived objects
C. it will convert the operator based on precedence
D. it converts the virtual base object to derived class
Solution: Because the dynamic_cast operator is used to convert from base class to derived class.
Q: How are many sequences of statements present in c++?
A. 4
B. 3
C. 5
D. 6
Solution: There are five sequences of statements. They are Preprocessor directives, Comments, Declarations, Function Declarations, Executable statements.
Q: The if..else statement can be replaced by which operator?
A. Bitwise operator
B. Conditional operator
C. Multiplicative operator
D. Addition operator
Solution: In the conditional operator, it will predicate the output using the given condition.
Q: The switch statement is also called as?
A. choosing structure
B. selective structure
C. certain structure
D. bitwise structure
Solution: The switch statement is used to choose the certain code to execute, So it is also called as selective structure.
Q: The destination statement for the goto label is identified by what label?
A. $
B. @
C. *
D. :
Solution: colon is used at the end of labels of goto statements.
Q: How many types of loops are there in C++?
A. 4
B. 2
C. 3
D. 1
Solution: There are four types of loop. They are the while, do while, nested, for the loop.
Q: Which looping process is best used when the number of iterations is known?
A. for
B. while
C. do-while
D. all looping processes require that the iterations be known
Solution: Because in for loop we are allowed to provide starting and ending conditions of loops, hence fixing the number of iterations of loops, whereas no such things are provided by other loops.

You Have Score    /10