This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your 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;The question was asked by my school principal while I was bunking the class.This is a very interesting question from This Pointer topic in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right choice is (d) [cv-qualifier-list] classType *const this; |
|
| 2. |
Which among the following is/are type(s) of this pointer?(a) const(b) volatile(c) const or volatile(d) intI had been asked this question in quiz.Question is from This Pointer in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The CORRECT answer is (c) CONST or volatile |
|
| 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 pointersThis question was posed to me during an interview for a job.This interesting question is from This Pointer topic in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The correct ANSWER is (a) To manipulate self-referential data STRUCTURES |
|
| 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 pointerThe question was posed to me in quiz.This question is from This Pointer in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The CORRECT OPTION is (c) Allowed assignments to this pointer |
|
| 5. |
The this pointers _____________________(a) Are modifiable(b) Can be assigned any value(c) Are made variables(d) Are non-modifiableI have been asked this question in an interview.Enquiry is from This Pointer topic in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The correct option is (d) Are non-modifiable |
|
| 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)The question was posed to me in my homework.I would like to ask this question from This Pointer topic in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The correct OPTION is (a) if(&object != this) |
|
| 7. |
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 referencingThe question was asked by my college director while I was bunking the class.The origin of the question is This Pointer in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» RIGHT answer is (b) This pointer can be used to GUARD against self-reference For explanation: The this pointer can be used to guard itself whenever self-reference is used. This ALLOWS accidental ADDRESS ACCESS. And accidental modification of data. |
|
| 8. |
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 functionThis question was posed to me during an internship interview.Asked question is from This Pointer in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Correct option is (c) Is available inside the member function using this pointer |
|
| 9. |
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)I had been asked this question during a job interview.My question is from This Pointer topic in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Correct ANSWER is (d) function(&object,parameter) |
|
| 10. |
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 functionI had been asked this question in quiz.The query is from This Pointer topic in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The CORRECT choice is (a) Address of the OBJECT is passed implicitly as an argument |
|
| 11. |
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 memberThe question was posed to me during an interview.The question is from This Pointer in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Correct option is (C) Doesn’t include the space TAKEN by this pointer |
|
| 12. |
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 itselfI had been asked this question in my homework.Enquiry is from This Pointer topic in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The correct option is (d) Isn’t part of object itself |
|
| 13. |
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 argumentsI had been asked this question in final exam.Asked question is from This Pointer in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
| Answer» | |
| 14. |
Which among the following is true?(a) this pointer is passed implicitly when member functions are called(b) this pointer is passed explicitly when member functions are called(c) this pointer is passed with help of pointer member functions are called(d) this pointer is passed with help of void pointer member functions are calledThe question was posed to me in homework.Asked question is from This Pointer in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right ANSWER is (a) this pointer is passed implicitly when member functions are called |
|
| 15. |
Which is the pointer which denotes the object calling the member function?(a) Variable pointer(b) This pointer(c) Null pointer(d) Zero pointerThis question was posed to me in class test.My query is from This Pointer in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right option is (b) This POINTER |
|
| 16. |
References to object are same as pointers of object.(a) True(b) FalseI got this question in an online quiz.I would like to ask this question from Pointer to Objects topic in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right choice is (b) False |
|
| 17. |
What should be done to prevent changes that may be made to the values pointed by the pointer?(a) Usual pointer can’t change the values pointed(b) Pointer should be made virtual(c) Pointer should be made anonymous(d) Pointer should be made constI have been asked this question by my school principal while I was bunking the class.Query is from Pointer to Objects in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right ANSWER is (d) Pointer should be MADE const |
|
| 18. |
How can the address stored in the pointer be retrieved?(a) Using * symbol(b) Using $ symbol(c) Using & symbol(d) Using @ symbolThe question was asked in examination.I want to ask this question from Pointer to Objects in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» RIGHT CHOICE is (C) USING & symbol The BEST I can explain: The & symbol must be used. This should be done such that the object should be preceded by & symbol and then the address should be stored in another variable. This is done to get the address where the object is stored. |
|
| 19. |
If a pointer to an object is created and the object gets deleted without using the pointer then __________(a) It becomes void pointer(b) It becomes dangling pointer(c) It becomes null pointer(d) It becomes zero pointerI had been asked this question in an online interview.The question is from Pointer to Objects in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right choice is (b) It becomes DANGLING pointer |
|
| 20. |
Which is the correct syntax to call a member function using pointer?(a) pointer->function()(b) pointer.function()(c) pointer::function()(d) pointer:function()This question was posed to me during an interview.My question is from Pointer to Objects topic in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The CORRECT OPTION is (a) POINTER->function() |
|
| 21. |
Which among the following is true?(a) The pointer to object can hold address only(b) The pointer can hold value of any type(c) The pointer can hold only void reference(d) The pointer can’t hold any valueThe question was asked in an interview for job.Origin of the question is Pointer to Objects topic in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The correct option is (a) The pointer to OBJECT can hold ADDRESS only |
|
| 22. |
Is name of an array of objects is also a pointer to object?(a) Yes, always(b) Yes, in few cases(c) No, because it represents more than one object(d) No, neverThe question was asked in an online interview.I'm obligated to ask this question of Pointer to Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right ANSWER is (a) YES, always |
|
| 23. |
Pointer to a base class can be initialized with the address of derived class, because of _________(a) derived-to-base implicit conversion for pointers(b) base-to-derived implicit conversion for pointers(c) base-to-base implicit conversion for pointers(d) derived-to-derived implicit conversion for pointersI have been asked this question by my school teacher while I was bunking the class.I want to ask this question from Pointer to Objects topic in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right answer is (a) derived-to-base IMPLICIT CONVERSION for pointers |
|
| 24. |
Can pointers to object access the private members of the class?(a) Yes, always(b) Yes, only if it is only pointer to object(c) No, because objects can be referenced from another objects too(d) No, neverI had been asked this question in homework.The query is from Pointer to Objects topic in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Correct choice is (d) No, never |
|
| 25. |
What is the size of an object pointer?(a) Equal to size of any usual pointer(b) Equal to size of sum of all the members of object(c) Equal to size of maximum sized member of object(d) Equal to size of voidI had been asked this question during an online interview.My enquiry is from Pointer to Objects in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The CORRECT option is (a) Equal to SIZE of any USUAL pointer |
|
| 26. |
A pointer _________________(a) Can point to only one object at a time(b) Can point to more than one objects at a time(c) Can point to only 2 objects at a time(d) Can point to whole class objects at a timeI have been asked this question in exam.This intriguing question comes from Pointer to Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The CORRECT answer is (a) Can point to only one object at a TIME |
|
| 27. |
If pointer to an object is declared __________(a) It can store any type of address(b) It can store only void addresses(c) It can only store address of integer type(d) It can only store object address of class type specifiedI have been asked this question in an interview for internship.The query is from Pointer to Objects topic in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right option is (d) It can only store object address of class type specified |
|
| 28. |
How does compiler decide the intended object to be used, if more than one object are used?(a) Using object name(b) Using an integer pointer(c) Using this pointer(d) Using void pointerThe question was asked by my school principal while I was bunking the class.The above asked question is from Pointer to Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right option is (C) Using this pointer |
|
| 29. |
Which operator should be used to access the members of the class using object pointer?(a) Dot operator(b) Colon to the member(c) Scope resolution operator(d) Arrow operatorI had been asked this question by my school teacher while I was bunking the class.I'd like to ask this question from Pointer to Objects in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right option is (d) ARROW operator |
|
| 30. |
Which is correct syntax for declaring pointer to object?(a) className* objectName;(b) className objectName;(c) *className objectName;(d) className objectName();I had been asked this question in an internship interview.I'm obligated to ask this question of Pointer to Objects in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Correct option is (a) className* objectName; |
|
| 31. |
Which language among the following doesn’t allow pointers?(a) C++(b) Java(c) Pascal(d) CThe question was posed to me during an interview.My enquiry is from Pointer to Objects in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The correct choice is (b) Java |
|
| 32. |
Assigning objects takes place while passing the arguments.(a) True(b) FalseThis question was posed to me during an interview.Asked question is from Assigning Objects topic in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» CORRECT answer is (b) False Explanation: The actual assignment doesn’t take place as the OBJECT might have got passed by REFERENCE. Also even if not by reference, the COPY CONSTRUCTOR is called to copy the values into the new object and not exactly the assignment operator. |
|
| 33. |
Which among the following is true?(a) We can use direct assignment for any object(b) We can use direct assignment only for different class objects(c) We must not use direct assignment(d) We can use direct assignment to same class objectsThis question was posed to me during an internship interview.My doubt stems from Assigning Objects in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The correct choice is (d) We can use direct assignment to same class objects |
|
| 34. |
Assigning reference to an object _________________(a) Will create another copy of the object(b) Will create two different copies of the object(c) Will not create any other copy of the object(d) Will not refer to the objectThe question was posed to me in an interview for internship.This interesting question is from Assigning Objects topic in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» CORRECT option is (c) Will not create any other copy of the OBJECT For EXPLANATION: When an object is assigned with another object. Same MEMORY location is used. There is no other copy of the object created. |
|
| 35. |
We can assign ______________________(a) Value of one reference variable to another(b) Value of any object to another(c) Value of any type to any object(d) Value of non – reference to another referenceThe question was asked in a job interview.Origin of the question is Assigning Objects in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» RIGHT answer is (a) VALUE of ONE reference variable to ANOTHER The best I can explain: Only the reference value can be assigned to another reference value. This is because both deal with the address. There is no TYPE mismatch hence we can assign them. |
|
| 36. |
How to make more than one object refer to the same object?(a) Initialize it to null(b) Initialize the object with another at declaration(c) Use constructor to create new object(d) Assign the address directlyThe question was asked at a job interview.I'd like to ask this question from Assigning Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right OPTION is (b) Initialize the object with another at declaration |
|
| 37. |
If more than one object refer to the same address, any changes made __________(a) Can be made visible to specific objects(b) Will be specific to one object only(c) From any object will be visible in all(d) Doesn’t changes the values of all objectsI had been asked this question in an online quiz.My question is based upon Assigning Objects in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right choice is (c) From any object will be visible in all |
|
| 38. |
Use of assignment operator ____________________(a) Changes its use, when used at declaration and in normal assignment(b) Doesn’t changes its use, whatever the syntax might be(c) Assignment takes place in declaration and assignment syntax(d) Doesn’t work in normal syntax, but only with declarationI have been asked this question in an online quiz.The origin of the question is Assigning Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» RIGHT choice is (a) Changes its use, when used at declaration and in NORMAL ASSIGNMENT Easiest EXPLANATION - The assignment operator if used at declaration then it uses copy constructor for the copying of objects. If used in simple assignment syntax then it uses copy assignment function. |
|
| 39. |
How many objects can be assigned to a single address?(a) Only 1(b) At most 7(c) At most 3(d) As many as requiredThis question was addressed to me during an internship interview.Enquiry is from Assigning Objects in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The correct answer is (d) As MANY as required |
|
| 40. |
In copy constructor definition, if non const values are accepted only ________(a) Only const objects will be accepted(b) Only non – const objects are accepted(c) Only const members will not get copied(d) Compiler generates an errorThe question was asked during an online interview.This intriguing question originated from Assigning Objects in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The correct answer is (B) Only NON – const objects are accepted |
|
| 41. |
Declaring a copy constructor doesn’t suppresses the compiler generated copy assignment operator.(a) True(b) FalseI got this question in an interview.I need to ask this question from Assigning Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Correct OPTION is (a) True |
|
| 42. |
If programmer doesn’t define any copy assignment operator then ____________________(a) Compiler gives an error(b) Program fails at run time(c) Compiler gives an implicit definition(d) Compiler can’t copy the member valuesI had been asked this question by my school principal while I was bunking the class.This interesting question is from Assigning Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right answer is (c) Compiler gives an implicit definition |
|
| 43. |
How the argument passed to a function get initialized?(a) Assigned using copy constructor at time of passing(b) Copied directly(c) Uses addresses always(d) Doesn’t get initializedThe question was asked during an online exam.This question is from Assigning Objects topic in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right ANSWER is (a) ASSIGNED using copy constructor at time of passing |
|
| 44. |
If an object is created and another object is assigned to it, then ________________(a) Copy constructor is called to copy the values(b) Object is copied directly to the object(c) Reference to another object is created(d) The new object is initialized to null valuesI got this question during an online exam.Asked question is from Assigning Objects topic in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» CORRECT option is (c) Reference to another OBJECT is created The BEST I can explain: The new object created, refers to the same address of the PREVIOUSLY created object. Now whenever new object changes any data member value, it will affect the previously existing object. |
|
| 45. |
When value of an object is assigned to another object ________________(a) It becomes invalid statement(b) Its values gets copied into another object(c) Its values gets address of the existing values(d) The compiler doesn’t execute that statementI had been asked this question by my school principal while I was bunking the class.The origin of the question is Assigning Objects topic in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» The correct option is (b) Its VALUES gets copied into another object |
|
| 46. |
Why temporary object is not created in return by reference?(a) Because compiler can’t create temporary objects(b) Because the temporary object is created within the function(c) Because return by reference just make the objects points to values memory location(d) Because return by reference just make the object point to nullThe question was asked in final exam.Asked question is from Returning Objects topic in division Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right option is (c) Because RETURN by reference just MAKE the OBJECTS points to values memory location |
|
| 47. |
If an object is being returned by value then __________________________(a) Its member values are made constant(b) Its member values have to be copied individually(c) Its member values are not used(d) Its member values are copied using copy constructorI had been asked this question during a job interview.I'm obligated to ask this question of Returning Objects topic in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Right answer is (d) Its member values are copied using copy CONSTRUCTOR |
|
| 48. |
Which among the following is true?(a) Two objects can point to the same memory location(b) Two objects can never point to the same memory location(c) Objects not allowed to point at a location already occupied(d) Objects can’t point to any addressThe question was asked in my homework.The query is from Returning Objects in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» RIGHT answer is (a) TWO objects can point to the same memory location The best I can EXPLAIN: When an object is created and instead of CALLING a constructor, another object is assigned to it. Both the objects point to the same memory location. This can be illustrated with help of return by reference. |
|
| 49. |
If an object is passed by reference to a function then it must be returned by reference.(a) True(b) FalseThis question was addressed to me in an internship interview.My doubt is from Returning Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» RIGHT answer is (b) False The best EXPLANATION: It is not compulsory to RETURN the object in the same way as it was passed. If the object is passed by reference then there is actually no NEED to return the object. Because the changes made inside the function will be visible on the original object of caller function also. |
|
| 50. |
Can we return an array of objects?(a) Yes, always(b) Ye, only if objects are having same values(c) No, because objects contain many other values(d) No, because objects are single entityThis question was addressed to me during a job interview.This interesting question is from Returning Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming |
|
Answer» Correct choice is (a) Yes, always |
|