

MCQOPTIONS
Saved Bookmarks
This section includes 39 Mcqs, each offering curated multiple-choice questions to sharpen your Object Oriented Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
Which is the correct syntax for declaring the type of this in a member function? |
A. | classType [cv-qualifier-list] *const this; |
B. | classType const[cv-qualifier-list] *this; |
C. | [cv-qualifier-list]*const classType this; |
D. | [cv-qualifier-list] classType *const this; |
Answer» E. | |
2. |
Which among the following is/are type(s) of this pointer? |
A. | const |
B. | volatile |
C. | const or volatile |
D. | int |
Answer» D. int | |
3. |
This pointer can be used directly to ___________ |
A. | To manipulate self-referential data structures |
B. | To manipulate any reference to pointers to member functions |
C. | To manipulate class references |
D. | To manipulate and disable any use of pointers |
Answer» B. To manipulate any reference to pointers to member functions | |
4. |
Earlier implementations of C++ ___________________ |
A. | Never allowed assignment to this pointer |
B. | Allowed no assignment to this pointer |
C. | Allowed assignments to this pointer |
D. | Never allowed assignment to any pointer |
Answer» D. Never allowed assignment to any pointer | |
5. |
The this pointers _____________________ |
A. | Are modifiable |
B. | Can be assigned any value |
C. | Are made variables |
D. | Are non-modifiable |
Answer» E. | |
6. |
Which syntax doesn’t execute/is false when executed? |
A. | if(&object != this) |
B. | if(&function !=object) |
C. | this.if(!this) |
D. | this.function(!this) |
Answer» B. if(&function !=object) | |
7. |
The address of the object _________________ |
A. | Can’t be accessed from inside the function |
B. | Can’t be accessed in the program |
C. | Is available inside the member function using this pointer |
D. | Can be accessed using the object name inside the member function |
Answer» D. Can be accessed using the object name inside the member function | |
8. |
Which is the correct interpretation of the member function call from an object, object.function(parameter); |
A. | object.function(&this, parameter) |
B. | object(&function,parameter) |
C. | function(&object,¶meter) |
D. | function(&object,parameter) |
Answer» E. | |
9. |
The result of sizeof() function __________________ |
A. | Includes space reserved for this pointer |
B. | Includes space taken up by the address pointer by this pointer |
C. | Doesn’t include the space taken by this pointer |
D. | Doesn’t include space for any data member |
Answer» D. Doesn’t include space for any data member | |
10. |
An object’s this pointer _____________________ |
A. | Isn’t part of class |
B. | Isn’t part of program |
C. | Isn’t part of compiler |
D. | Isn’t part of object itself |
Answer» E. | |
11. |
The this pointer is accessible __________________ |
A. | Within all the member functions of the class |
B. | Only within functions returning void |
C. | Only within non-static functions |
D. | Within the member functions with zero arguments |
Answer» D. Within the member functions with zero arguments | |
12. |
Which is the pointer which denotes the object calling the member function? |
A. | Variable pointer |
B. | This pointer |
C. | Null pointer |
D. | Zero pointer |
Answer» C. Null pointer | |
13. |
char *ptr;char myString[] = "abcdefg";ptr = myString;ptr += 5;what string does ptr point to in the sample code above? |
A. | g |
B. | fg |
C. | efg |
D. | defg |
E. | cdefg |
Answer» B. fg | |
14. |
What would be the output for the following Turbo C code?#include
|
A. | 4 |
B. | 4 |
C. | 2 |
D. | 3 |
E. | 3 |
Answer» E. 3 | |
15. |
Which of the following statements are true after execution of the program.void main(){int a[10], i, *p;a[0] = 1;a[1] = 2;p = a;(*p)++;} |
A. | [1] = 3 |
B. | [0] = 2 |
C. | [1] = 2 |
D. | [0] = 3 |
E. | ompilation error |
Answer» C. [1] = 2 | |
16. |
Find the output of the following program.void main(){int i=10;/* assume address of i is 0x1234ABCD */int *ip=&i;int **ipp=&&i;printf("%x,%x,%x", &i, ip, *ipp);} |
A. | x1234ABCD, 0x1234ABCD, 10 |
B. | x1234ABCD, 0x1234ABCD, 0x1234ABCD |
C. | x1234ABCD, 10, 10 |
D. | yntax error |
E. | untime error |
Answer» E. untime error | |
17. |
Find the output of the following program.void main(){printf("%d, %d", sizeof(int *), sizeof(int **));} |
A. | , 0 |
B. | , 2 |
C. | , 2 |
D. | , 4 |
E. | , 4 |
Answer» D. , 4 | |
18. |
A function 'p' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as |
A. | nt(*p(char *))[] |
B. | nt *p(char *)[] |
C. | nt (*p) (char *)[] |
D. | one of these. |
Answer» B. nt *p(char *)[] | |
19. |
#include
|
A. | 0, 10 |
B. | 0, 11 |
C. | 1, 10 |
D. | 1, 11 |
Answer» E. | |
20. |
Comment on the following?const int *ptr; |
A. | e cannot change the value pointed by ptr. |
B. | e cannot change the pointer ptr itself. |
C. | oth of the above |
D. | e can change the pointer as well as the value pointed by it. |
Answer» B. e cannot change the pointer ptr itself. | |
21. |
The declarationint (*p) [5];means |
A. | is one dimensional array of size 5, of pointers to integers. |
B. | is a pointer to a 5 elements integer array. |
C. | he same as int*p[ |
D. | one of these. |
Answer» C. he same as int*p[ | |
22. |
The operator>and |
A. | he pointers point to data of similar type. |
B. | he pointers point to structure of similar data type. |
C. | he pointers point to elements of the same array. |
D. | one of these. |
Answer» D. one of these. | |
23. |
What will be the output of the following program code?#include
|
A. | 44 |
B. | 00 |
C. | 33 |
D. | 33 |
E. | arbage Value |
Answer» D. 33 | |
24. |
What will be printed after compiling and running the following code?main(){char *p;printf("%d %d",sizeof(*p), sizeof(p));} |
A. | 1 |
B. | 2 |
C. | 1 |
D. | 2 |
Answer» C. 1 | |
25. |
What will be the output of the following program code?#include
|
A. | rror |
B. | 0 |
C. | 0 |
D. | one of these. |
Answer» D. one of these. | |
26. |
What will be the output of the following program?#include
|
A. | ompiler time error |
B. | egmentation fault/runtime crash |
C. | 0 |
D. | ndefined behavior |
Answer» B. egmentation fault/runtime crash | |
27. |
The statementint **a; |
A. | s illegal |
B. | s legal but meaningless |
C. | s syntactically and semantically correct |
D. | one of these. |
Answer» D. one of these. | |
28. |
Determine output:#include
|
A. | q |
B. | epends on the compiler |
C. | nullq where x can be p or nullp depending on the value of NULL |
D. | ullp nullq |
Answer» E. | |
29. |
Comment on the following pointer declaration?int *ptr, p; |
A. | tr is a pointer to integer, p is not. |
B. | tr and p, both are pointers to integer. |
C. | tr is pointer to integer, p may or may not be. |
D. | tr and p both are not pointers to integer. |
Answer» B. tr and p, both are pointers to integer. | |
30. |
Choose the best answer.Prior to using a pointer variable |
A. | t should be declared. |
B. | t should be initialized. |
C. | t should be both declared and initialized. |
D. | one of these. |
Answer» D. one of these. | |
31. |
Determine Output:main(){char *str1 = "abcd";char str2[] = "abcd";printf("%d %d %d", sizeof(str1), sizeof(str2), sizeof("abcd"));} |
A. | 5 5 |
B. | 4 4 |
C. | 5 5 |
D. | 4 5 |
Answer» D. 4 5 | |
32. |
Determine Output:void main(){char far *farther, *farthest;printf("%d..%d", sizeof(farther), sizeof(farthest));} |
A. | ..2 |
B. | ..2 |
C. | ..4 |
D. | ..4 |
Answer» B. ..2 | |
33. |
WHICH_SYNTAX_DOESN‚ÄÖ√Ñ√∂‚ÀÖ√Ë‚ÀÖ¬•T_EXECUTE/IS_FALSE_WHEN_EXECUTED??$# |
A. | if(&object != this) |
B. | if(&function !=object) |
C. | this.if(!this) |
D. | this.function(!this) |
Answer» B. if(&function !=object) | |
34. |
WHICH_AMONG_THE_FOLLOWING_IS_TRUE??$ |
A. | This pointer can be used to guard against any kind of reference |
B. | This pointer can be used to guard against self-reference |
C. | This pointer can be used to guard from other pointers |
D. | This pointer can be used to guard from parameter referencing |
Answer» C. This pointer can be used to guard from other pointers | |
35. |
Earlier implementations of C++ ___________________$ |
A. | Never allowed assignment to this pointer |
B. | Allowed no assignment to this pointer |
C. | Allowed assignments to this pointer |
D. | Never allowed assignment to any pointer |
Answer» D. Never allowed assignment to any pointer | |
36. |
The this pointers _____________________$ |
A. | Are modifiable |
B. | Can be assigned any value |
C. | Are made variables |
D. | Are non-modifiable |
Answer» E. | |
37. |
The address of the object ________________? |
A. | Can’t be accessed from inside the function |
B. | Can’t be accessed in the program |
C. | Is available inside the member function using this pointer |
D. | Can be accessed using the object name inside the member function |
Answer» D. Can be accessed using the object name inside the member function | |
38. |
Whenever non-static member functions are called _______________ |
A. | Address of the object is passed implicitly as an argument |
B. | Address of the object is passed explicitly as an argument |
C. | Address is specified globally so that the address is not used again |
D. | Address is specified as return type of the function |
Answer» B. Address of the object is passed explicitly as an argument | |
39. |
An object’s this pointer _____________________$ |
A. | Isn’t part of class |
B. | Isn’t part of program |
C. | Isn’t part of compiler |
D. | Isn’t part of object itself |
Answer» E. | |