C++ Programming Multiple Choice Question - Pointers
This section focuses on the "Pointers" in C++ programming langauge. These Multiple Choice Questions (MCQ) should be practiced to improve the C++ programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. Which of the following is the correct way to declare a pointer ?
A. int *ptr
B. int ptr
C. int &ptr
D. All of the above
View Answer
Ans : A
Explanation: int *ptr is the correct way to declare a pointer.
2. Which of the following gives the [value] stored at the address pointed to by the pointer : ptr?
A. Value(ptr)
B. ptr
C. &ptr
D. *ptr
View Answer
Ans : D
Explanation: *ptr gives the [value] stored at the address pointed to by the pointer : ptr.
3. A pointer can be initialized with
A. Null
B. Zero
C. Address of an object of same type
D. All of the above
View Answer
Ans : D
Explanation: A pointer can be initialized with null, zero and Address of an object of same type.
4. Choose the right option
string* x, y;
A. x is a pointer to a string, y is a string
B. y is a pointer to a string, x is a string
C. Both x and y are pointers to string types
D. none of the above
View Answer
Ans : A
Explanation: * is to be grouped with the variables, not the data types
5. Generic pointers can be declared with__________ .
A. auto
B. void
C. asm
D. None of the above
View Answer
Ans : B
Explanation: Generic pointers can be declared with void.
6. What is size of generic pointer in c?
A. 0
B. 1
C. 2
D. Null
View Answer
Ans : C
Explanation: Size of any type of pointer is 2 byte.
7. Which from the following is not a correct way to pass a pointer to a function?
A. Non-constant pointer to non-constant data
B. A non-constant pointer to constant data
C. A constant pointer to non-constant data
D. All of the above
View Answer
Ans : D
Explanation: All of the above is not a correct way to pass a pointer to a function.
8. What does the following statement mean?
int (*fp)(char*)
A. Pointer to a pointer
B. Pointer to an array of chars
C. Pointer to function taking a char* argument and returns an int
D. Function taking a char* argument and returning a pointer to int
View Answer
Ans : C
Explanation: The statement means Pointer to function taking a char* argument and returns an int
9. A void pointer cannot point to which of these?
A. Methods in c++
B. Class member in c++
C. Both A & B
D. None of the above
View Answer
Ans : B
Explanation: Because the class member will have a definite type, So it cannot pointed by a void pointer.
10. Referencing a value through a pointer is called
A. Direct calling
B. Indirection
C. Pointer referencing
D. All of the above
View Answer
Ans : B
Explanation: Referencing a value through a pointer is called Indirection.
Also check :
Discussion