Test Series - cpp

Test Number 39/102

Q: Which is used to tell the computer that where a pointer is pointing to?
A. dereference
B. reference
C. heap operations
D. binary operations
Solution: dereference is used to tell the computer where a pointer is pointing to it.
Q: Which is used to do the dereferencing?
A. pointer without asterix
B. value without asterix
C. pointer with asterix
D. value with asterix
Solution: Dereferencing is using a pointer with asterix. For example, *(abc).
Q: Pick out the correct option.
A. References automatically dereference without needing an extra character
B. References automatically dereference with an extra character
C. Reference will not dereference
D. Reference automatically dereference with extra space and character
Solution: References automatically dereference without needing an extra character.
Q: What does the dereference operator will return?
A. rvalue equivalent to the value at the pointer address
B. lvalue equivalent to the value at the pointer address
C. it will return nothing
D. it will return boolean values
Solution: It operates on a pointer variable, and returns an l-value equivalent to the value at the pointer address.
Q: Pick out the correct statement.
A. the null pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to null
B. the null pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to the memory address
C. rvalue equivalent to the value at the pointer address
D. null pointer will not return anything
Solution: The null pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to null.
Q: Which operator works only with integer variables?
A. increment
B. decrement
C. both increment & decrement
D. binary operator
Solution: Because increment and decrement operator increases increasing and decreasing values of values and no such things define in strings so cannot be used with strings. Also they cannot be used with floats and doubles because there is no way to fix how much the value should be increased or decreased if increment or decrement operator is applied on such variables. That’s why both these operators only works with integer values.
Q: How many types are there in increment/decrement operator?
A. 1
B. 2
C. 3
D. 4
Solution: There are two types of increment/decrement. They are postfix and prefix.
Q: Pick out the correct statement.
A. Increment operator ++ adds 1 to its operand
B. Increment operator ++ adds 2 to its operand
C. Decrement operator ++ subtracts 1 to its operand
D. Decrement operator ++ subtracts 3 to its operand
Solution: Increment operator are used to increase the values of any integer variable by 1.
Q: Pick out the correct statement.
A. Pre Increment is faster than post-increment
B. post-increment is faster than Pre Increment
C. pre increment is slower than post-increment
D. pre decrement is slower than post-increment
Solution: Because Pre Increment take one-byte instruction & post increment takes two-byte instruction.
Q: Which concepts does the Pre Increment use?
A. call by value
B. call by reference
C. queue
D. call by name
Solution: call by reference because the changes are reflected back to the same memory cells/variables.

You Have Score    /10