Object Oriented MCQ Number 01262

Object Oriented MCQ Set 1

1. What is the term used to indicate the variable and constants of a class?
a) Data members
b) Variables of class
c) Data characters
d) Constants

Answer

Answer: a [Reason:] The variables inside a class are termed data members of the class. It is not a mandatory rule but variables are used to refer usual variables used in functions or globally. The term is given because the values stored in those variables represent some kind of data related to class.

2. Data members ____ (C++)
a) Can be initialized with declaration in classes
b) Can be initialized only with help of constructors
c) Can be initialized either in declaration or by constructor
d) Can’t be initialized

Answer

Answer: b [Reason:] The data members are not property of class, those are property of the instances of the class. And the memory for the data members are not reserved until a constructor is called. Hence we use constructors for their initialization after the memory is reserved.

3. Which among the following is true for data members?
a) Private data members can be initialized with declaration in class
b) Static members are initialized in constructors
c) Protected data members can be initialized in class directly
d) Static data members are defined outside class, not in constructor

Answer

Answer: d [Reason:] Static members are not property of instances of classes. Those are shared by all the object of classes. Hence those are defined outside the constructor, so as to make them common for all the objects.

4. What should be done for data member to be of user defined structure type?
a) The structure must have been defined before class.
b) The structure must have been defined after the class definition
c) The structure must be predefined
d) The structure type data members can’t be used

Answer

Answer: a [Reason:] The structure must have been defined prior to its use. If the structure is not defined, then the memory space will not be allocated for its members. This leads to undefined use of new data types.

5. How many data members can a class contain?
a) 27
b) 255
c) 1024
d) As many as required

Answer

Answer: d [Reason:] Any class can have as many data members as required. The only restriction that may arise is when there is not enough memory space. This gives flexibility to define a class with best properties possible.

6. How to access data members of a class?
a) Dot operator
b) Arrow operator
c) Dot or arrow as required
d) Dot, arrow or direct call

Answer

Answer: c [Reason:] The data members can never be called directly. Dot operator is used to access the members with help of object of class. Arrow is usually used if pointers are used.

7. To create a pointer to a private data member of a class, outside the class, which among the following is correct?
a) Return the address of the private data member using a member function
b) Access the private member using a pointer outside class
c) Declare the member as pointer inside the class
d) Not possible to create pointer to a private member

Answer

Answer: a [Reason:] We can call a public member function and return the address of any private data member. Though the pointer being returned must be defined inside class itself. And the returned address can be stored in a pointer.

8. Which among the following is true for use of setter() and getter() function?
a) Considered best for manipulating data values
b) Considered the only proper way to manipulate the values
c) Considered specially for private members manipulation
d) Considered a red flag, and not recommended for large scale use

Answer

Answer: d [Reason:] This concept of getter and setter functions is not acceptable if used too much. This is considered to be inappropriate in OOP perspective. Though it is commonly used, it doesn’t work according to OOP concepts at some higher level of understanding.

9. What is the output of following code?

int n=10;// global
class A()
{
private : int n;
public : int m;
	A()
{ 
		n=100; m=50;
}
void disp()
{
cout<<”n”<<m<<n;
};

a) 1050100
b) 1005010
c) n5010
d) n50100

Answer

Answer: d [Reason:] In cout we have specified n as a string to be printed. And m is a variable so its value gets printed. And global variable will not be used since local variable have more preference.

10. The static member functions can only use ________
a) Static data members
b) Private data members
c) Protected data members
d) Constant data members

Answer

Answer: a [Reason:] The static member functions can only access static data members. This is because the static member function can’t work with the properties that change object to object. It is mandatory that only the common properties of all the objects be used. And only static data members are common to all as those are property of class.

11. A class can have self-referential data members.
a) True
b) False

Answer

Answer: b [Reason:] The data members in a class can never refer to own class type. This is not possible because the data members should have some memory allocated for its object before the self-reference is used, but class must call constructor for that. Hence not possible.

12. What is the keyword used to make data members have same value?
a) static
b) const
c) double
d) abstract

Answer

Answer: b [Reason:] The keyword const can be used anywhere to make the variable have same value all the time. This restriction is made to use the same value whenever required. Also, this can restrict accidental changes.

13. Which data members can be inherited but are private to a class?
a) Private
b) Protected
c) Protected and Static
d) Privately inherited

Answer

Answer: b [Reason:] Static member’s inheritance also depends on the type of specifier they have. Only the protected members can be inherited but remain private to class. If static members are defined in private access, they won’t be allowed for inheritance.

14. The arguments passed to member functions by reference are considered as data members of class.
a) True
b) False

Answer

Answer: b [Reason:] This is a wrong statement. As only the data defined inside class is considered as its member. But even if a variable is passed by reference it would be the same variable that is outside the class. Hence it can’t be considered class member.

15. Which among the following is not allowed for data member declaration?
a) int a;
b) static int a;
c) abstract a;
d) Boolean a;

Answer

Answer: c [Reason:] The abstract keyword in declaration of data members is not allowed. This is because the abstract keyword features can’t be used with the data members of the class. We can have all other syntax given, but not abstract.

Object Oriented MCQ Set 2

1. What are default arguments?
a) Arguments which are not mandatory to be passed
b) Arguments with default value that aren’t mandatory to be passed
c) Arguments which are not passed to functions
d) Arguments which always take same data value

Answer

Answer: b [Reason:] The arguments which are assigned with some default value. Since some value is already given, it is not mandatory to pass those arguments. They can be used directly.

2. Which is correct condition for the default arguments?
a) Those must be declared as last arguments in argument list
b) Those must be declared first in the argument list
c) Those can be defined anywhere in the argument list
d) Those are declared inside the function definition

Answer

Answer: a [Reason:] The default arguments must be declared at last in the argument list. This is to ensure that the arguments doesn’t create ambiguity. The normal arguments should be passed first.

3. If a member function have to be made both zero argument and parameterized constructor, which among the following can be the best option?
a) Two normal and one default argument
b) At least one default argument
c) Exactly one default argument
d) Make all the arguments default

Answer

Answer: d [Reason:] All the arguments must be made default. This will make sure that none of the arguments are mandatory to be passed. Which in turn means that the function can work without any argument and can be passed with arguments too.

4. Which among the following function can be called without arguments?
a) void add(int x, int y=0)
b) void add(int=0)
c) void add(int x=0, int y=0)
d) void add(char c)

Answer

Answer: c [Reason:] For the function to be called without arguments, either it must have zero arguments or it must have all the default arguments. Here the function in option c have all the default arguments and hence can be called directly with zero argument.

5. If a function have all the default arguments but still some values are passed to the function then ________
a) The function will use the values passed to it
b) The function will use the default values as those are local
c) The function can use any value whichever is higher
d) The function will choose the minimum values

Answer

Answer: a [Reason:] The function will use the values passed explicitly to it. The default values will be ignored. The default values are used only in case the values are not passed explicitly to the function.

6. Which among the following is correct?
a) void test(int x=0, int y, int z=0)
b) void test(int x=0,int=0)
c) void test(int x,int y=0)
d) void test(int x=’c’,int y)

Answer

Answer: c [Reason:] The default arguments must be mentioned at last in the argument list. Also the type of values assigned must match with the argument type. All the default arguments must be mentioned at last, none of the normal arguments should come in between the default arguments list.

7. What function will be called with the independent syntax “test(5,6,7);”?
a) void test(int x, int y)
b) void test(int x=0,int y,int z)
c) int test(int x=0,y=0,z=0)
d) void test(int x,int y, int z=0)

Answer

Answer: d [Reason:] There are three arguments that are getting passed to the function test(). Only the last option have all the default argument at last in the argument list. And the total number of the arguments is three. The third option is wrong because the return type is int and the syntax given is independent which means it doesn’t return any value.

8. Which among the following is wrong call to the function void test(int x, int y=0, int z=0)?
a) test(5,6,7);
b) test(5);
c) test();
d) test(5,6);

Answer

Answer: c [Reason:] The function must be passed with at least one argument. There is two default arguments and one normal argument which must be passed with some value. Hence third call to the function is wrong as it doesn’t pass even a single parameter to the function

9. Default arguments are ___
a) Only allowed in the parameter list of the function declaration
b) Only allowed in the return type of the function declaration
c) Only allowed with the class name definition
d) Only allowed with the integer type values

Answer

Answer: a [Reason:] The default arguments are only allowed in the parameter list of the function arguments. This rule was not applicable in the beginning versions of c++ but later from c++ 14th version it has been implemented. This is the only way to use default arguments.

10. Which among the following is false for default arguments?
a) Those are not allowed with declaration of pointer to functions
b) Those are not allowed with the reference to functions
c) Those are not allowed with the typedef declarations
d) Those are allowed with pointer and reference to function declaration

Answer

Answer: d [Reason:] The statements given are true because that is a feature given to make the programming more flexible and have some security with accidental changes at same time. The last option is false because it is not a rule defined. It is an opposite statement to the rules defined for default arguments.

11. The non-template functions can be added with default arguments to already declared functions ____
a) If and only if the function is declared again in the same scope
b) If and only if the function is declared only once in the same scope
c) If and only if the function is declared in different scope
d) If and only if the function is declared twice in the program

Answer

Answer: a [Reason:] The non-template functions can also be added with default arguments. This can be done even if the functions were defined earlier. This is because the call to the function won’t be affected. The function can still be used in the same way as it was used earlier.

12. The using declaration ____
a) Doesn’t carry over the default values
b) Carries over the known default arguments
c) Carries over only the normal arguments
d) Carries over only few default arguments

Answer

Answer: b [Reason:] The using-declaration carries over all the known default arguments. This is a common feature as the usage doesn’t gets affected even if the default arguments are added. This comes under flexible programming.

13. The names given to the default arguments are only looked up and ____. And are bound during declaration.
a) Checked for availability
b) Checked for random access
c) Checked for accessibility
d) Checked for feasibility

Answer

Answer: c [Reason:] The names given to the default arguments are bound at time of declaration but are only checked for accessibility and to get bounded. This is mainly to bind those members during declaration.

14. The default argument get bound during declaration ____
a) And are never executed
b) And are executed simultaneously
c) But are executed only if priority is given
d) But are executed during function call

Answer

Answer: d [Reason:] The default argument are bound at time of declaration. That is an implicit functioning. But those are executed only when the function is called. Otherwise those will never get executed.

15. The virtual function overrides ______
a) Do not acquire base class declaration of default arguments
b) Do acquire base class declaration of default arguments
c) Do not link with the default arguments of base class
d) Do link with the default argument but only of derived classes

Answer

Answer: a [Reason:] The virtual function overrides do not acquire the base class declaration of default arguments. Even if a call to the virtual function is made, static type of the object decides the default arguments to be used.

Object Oriented MCQ Set 3

1. What is delete operator?
a) Deallocates a block of memory
b) Deallocates whole program memory
c) Deallocates only primitive data memory
d) Deallocates all the data reserved for a class

Answer

Answer: a [Reason:] The delete operator is reverse process of new operator. It deallocates all the memory allocated for an object. The object can be of any type. The delete operator completely destroys an object so that the resources can be used for other purposes.

2. If an object is allocated using new operator ______
a) It should be deleted using delete operator
b) It can’t be deleted using delete operator
c) It may or may not be deleted using delete operator
d) The delete operator is not applicable

Answer

Answer: a [Reason:] The new operator allocates an object in memory and hence the memory allocation is bit different from usual allocation of an object. The delete operator can be used to delete the memory allocated for an object.

3. Does delete return any value?
a) Yes, positive value
b) Yes, negative value
c) Yes, zero value
d) No

Answer

Answer: d [Reason:] The delete operator doesn’t return any value. Its function is to delete the memory allocated for an object. This is done in reverse way as that new operator works.

4. Which type of value is resulted from the delete operator?
a) void
b) void pointer
c) null pointer
d) null

Answer

Answer: a [Reason:] The result of delete operator is void. The values returned is of no use to the program or any other system function hence the return type is not defined for the delete operator.

5. If delete is used to delete an object which was not allocated using new ___
a) Then out of memory error arises
b) Then unreachable code error arises
c) Then unpredictable errors may arise
d) Then undefined variable error arises

Answer

Answer: c [Reason:] When the delete operator is used with the objects that were not allocated using new operator then unpredictable errors may arise. This is because the delete can’t perform the required actions on the type of memory allocated for the object.

6. Delete operator _____
a) Can be used on pointers with null value
b) Can be used on pointers with void value
c) Can be used on pointer with value 0
d) Can be used on pointer with any value

Answer

Answer: c [Reason:] The delete operator can be used on pointers with the value 0. This actually means that when new operator fails and return value 0 then deleting the result of failed new remains harmless. Hence the deletion is possible.

7. When delete operator is used ___ (If object has a destructor)
a) Object destructor is called after deallocation
b) Object destructor is called before deallocation
c) Object destructor is not used
d) Object destructor can be called anytime during destruction

Answer

Answer: b [Reason:] The destructor is called before the memory is deallocated for any object. The destructor call initiates the destruction process and the deallocation of memory takes place.

8. If delete is applied to an object whose l-value is modifiable, then ___ after the object is deleted.
a) Its value is defined as null
b) Its value is defined as void
c) Its value is defined as 0
d) Its value is undefined

Answer

Answer: d [Reason:] After performing delete operation on an object whole l-value is modifiable, its values becomes undefined. This is done so as to denote that the memory space is available to be used for other puposes.

9. How many variants of delete operator are available?
a) Only 1
b) Only 2
c) Only 3
d) Only 4

Answer

Answer: b [Reason:] There are two variants of delete operator. One is for object deletion. Other is for deletion of object array.

10. Which is the correct syntax to delete a single object?
a) delete *objectName;
b) objectName delete;
c) delete objectName;
d) objectName *delete;

Answer

Answer: c [Reason:] The object to be deleted is mentioned after the keyword delete. This deletes the object from memory and free up the memory that was acquired by the object.

11. Which is the correct syntax to delete array of objects?
a) delete [] objectName;
b) delete * objectName;
c) objectName[] delete;
d) delete objectName[];

Answer

Answer: a [Reason:] The object array that has to be deleted is mentioned after the keyword delete. But after delete, empty square brackets have to be given to denote that the deletion have to be done on array of objects.

12. Which cases among the following produces the undefined result?
a) delete [] on an independent object
b) delete on an object array
c) delete [] on an object and delete on object array
d) Undefined result is never produced

Answer

Answer: c [Reason:] The undefined result is always produced when we try to use delete [] with a single object. Because the type of deletion mismatches. Same in case where we try to apply delete to an object array.

13. The delete operator ______
a) Invokes function operator delete
b) Invokes function defined by user to delete
c) Invokes function defined in global scope to delete object
d) Doesn’t invoke any function

Answer

Answer: a [Reason:] The delete operator invokes the function operator delete. This function in turn performs all the delete operations on the mentioned object. This is ensures safe deletion.

14. For objects that are not of class type ________
a) Global delete operator is invoked
b) Local delete operator is invoked
c) Global user defined function is invoked
d) Local function to delete object is called

Answer

Answer: a [Reason:] The global delete operator is called to delete the objects that are not of class type. Class type includes class, union or struct. All objects of these types can be deleted using the global delete operator.

15. The delete operator ____
a) Can be defined for each class
b) Can’t be defined for each class
c) Can be defined globally only
d) Can’t be defined in a program explicitly

Answer

Answer: a [Reason:] The delete operator can be defined for each class explicitly. If there is a class for which delete is not defined then the global delete operator is used. The definition of delete operator for each class is not necessary.

Object Oriented MCQ Set 4

1. Which among the following is best definition of a derived class?
a) A child class
b) A class which inherits one or more classes
c) A class with keyword derived
d) A class with more than one constructor

Answer

Answer: b [Reason:] Any class which inherits one or more classes is a derived class. The only condition is it must inherit at least one class in order to be called as a derived class.

2. Which among the following is inherited by a derived class from base class?
a) Data members only
b) Member functions only
c) All the members except private members
d) All the members of base class

Answer

Answer: c [Reason:] The class inheriting another class, inherits all the data members and member functions which are not private. This is done to ensure the security features with maximum flexibility.

3. If there is a derived class in a program, how many classes must be in that program?
a) 1
b) 2
c) 3
d) 4

Answer

Answer: b [Reason:] If there is a derived class in a program, there must be at least 2 classes in that program. One is a base class and another derived class. Hence at least 2 classes must be there.

4. Which members can never be accessed in derived class from the base class?
a) Private
b) Protected
c) Public
d) All except private

Answer

Answer: d [Reason:] There is no restriction for a derived class to access the members of the base class until and unless the members are private. Private member are declared so that those members are not accessible outside the class.

5. How many types of inheritance are supported in C++ for deriving a class?
a) 1
b) 2
c) 3
d) 4

Answer

Answer: c [Reason:] There are three types of inheritance possible. Private inheritance, protected inheritance, and public inheritance. The inheritance defines the access specifier to be used with the inherited members in the derived class.

6. How many derived class can a single base class have?
a) 1
b) 2
c) 3
d) As many are required

Answer

Answer: d [Reason:] There is no restriction on how many classes can inherit a single base class. Hence there can be as many derived classes as required in a program from a single base class.

7. Which among the following is correct?
a) Friend function of derived class can access non-private members of base class
b) Friend function of base class can access derived class members
c) Friend function of derived class can access members of only derived class
d) Friend function can access private members of base class of a derived class

Answer

Answer: a [Reason:] The friend function of a class can access the non-private members of base class. The reason behind is that the members of base class gets derived into the derived class and hence become members of derived class too. Hence a friend function can access all of those.

8. If a class is being derived using more than two base classes, which inheritance will be used?
a) Single
b) Multi-level
c) Hierarchical
d) Multiple

Answer

Answer: d [Reason:] The statement given is definition of multiple inheritance with respect to the derived class. The concept can be illustrated with many other samples but the main aspects are base class and derived class only.

9. Derived class is also known as ________ class.
a) Subclass
b) Small class
c) Big class
d) Noticeable class

Answer

Answer: a [Reason:] It is just another name given to the derived classes. This is used while denoting all the derived classes subsequent to a super class.

10. If class A is derived from another derived class B which is derived from class C, which class will have maximum level of abstraction?
a) Class A
b) Class B
c) Class C
d) All have same level of abstraction

Answer

Answer: c [Reason:] The abstraction level of class C will be maximum. This is because the parent class have higher level of abstraction. Hence the parent of all other class will have maximum level of abstraction.

11. If base class is an abstract class then derived class ________ the undefined functions.
a) Must define
b) Must become another abstract class or define
c) Must become parent class for
d) Must implement 2 definitions of

Answer

Answer: b [Reason:] The function must be defined in the program which are not defined in the base class. Hence the class must be defined as abstract of implement the function definition in it.

12. How many classes can be derived from a derived class?
a) Only 1
b) At most 1
c) At least 1
d) As many as required

Answer

Answer: d [Reason:] When a class is to be derived from another derived class, the derived class behaves as a normal base class hence there are no restriction on how many class can be derived from a derived class. The derived class again behaves as a normal super class.

13. The members of a derived class can never be derived.
a) True
b) False

Answer

Answer: b [Reason:] This is not true that the members of a derived class can’t be derived. All the classes are considered to be a normal class when used for derivation. The members can be derived with respect to their access specifiers.

14. Which feature is not related to the derived classes among the following?
a) Inheritance
b) Encapsulation
c) Run time memory management
d) Compile time function references

Answer

Answer: c [Reason:] The memory management is the feature that is not necessary for derived classes that will be a part of whole program. The functions references must be resolved for their proper use if inheritance is used.

15. Deriving a class in such a way that that the base class members are not available for further inheritance is known as ___
a) Public inheritance
b) Protected inheritance
c) Protected or private inheritance
d) Private inheritance

Answer

Answer: d [Reason:] The private members of a class can never be derived to another class. When a class derives another class using private inheritance, all the members become private members of the derived class. Hence these member won’t be available for further inheritance.

Object Oriented MCQ Set 5

1. Which among the following describes a destructor?
a) A special function that is called to free the resources, acquired by the object
b) A special function that is called to delete the class
c) A special function that is called anytime to delete an object
d) A special function that is called to delete all the objects of a class

Answer

Answer: a [Reason:] It is used to free the resources that the object might had used in its lifespan. The destructors are called implicitly whenever an object’s life ends.

2. When a destructor is called?
a) After the end of object life
b) Anytime in between object’s lifespan
c) At end of whole program
d) Just before the end of object life

Answer

Answer: d [Reason:] The destructor is called just before the object go out of scope or just before its life ends. This is done to ensure that all the resources reserved for the object are used and at last, are made free for others.

3. Which among the following is correct for abstract class destructors?
a) It doesn’t have destructors
b) It has destructors
c) It may or may not have destructors
d) It contains an implicit destructor

Answer

Answer: a [Reason:] It doesn’t have destructors. Since an abstract class don’t have constructors, and hence can’t have instances. Having this case, the abstract classes doesn’t have destructors too, because that would be of no use here.

4. If in multiple inheritance, class C inherits class B, and Class B inherits class A. In which sequence are their destructors called, if an object of class C was declared?
a) ~C() then ~B() then ~A()
b) ~B() then ~C() then ~A()
c) ~A() then ~B() then ~C()
d) ~C() then ~A() then ~B()

Answer

Answer: c [Reason:] The destructors are always called in the reverse order of how the constructors were called. Here class A constructor would have been created first if Class C object is declared. Hence class A destructor is called at last.

5. Choose the correct sequence of destructors being called for the following code:
class A{ };
class B{ };
class C: public A, public B{ };
a) ~A(), ~B(), ~C()
b) ~B(), ~C(), ~A()
c) ~A(), ~C(), ~B()
d) ~C(), ~B(), ~A()

Answer

Answer: d [Reason:] In multiple inheritance, the constructors are called in the sequence of how they are written in inheritance sequence. And the destructors will be called in the reverse order. This can be cross verified just by printing a message from each destructor defined in classes.

6. When is the destructor of a global object called?
a) Just before end of program
b) Just after end of program
c) With the end of program
d) Anytime when object is not needed

Answer

Answer: a [Reason:] This is because the lifespan of global object is from start of the program, till the end of the program. And hence program end is the end of global object too. Just before the end of program, the destructor will be called to free the acquired resources by the objects.

7. How the constructors and destructors can be differentiated?
a) Destructor have a return type but constructor doesn’t
b) Destructors can’t be defined by the programmer, but constructors can be defined
c) Destructors are preceded with a tilde (~) symbol, and constructor doesn’t
d) Destructors are same as constructors in syntax

Answer

Answer: c [Reason:] The destructors are preceded with the tilde (~) symbol. The name is same as that of the class. These also doesn’t have any return type.

8. Destructors doesn’t accept parameters.
a) True
b) False

Answer

Answer: a [Reason:] The destructors doesn’t accept the arguments. Those are just used to free up the resources.

9. Destructors can be ________
a) Abstract type
b) Virtual
c) Void
d) Any type depending on situation

Answer

Answer: b [Reason:] The destructors can be virtual. It is actually advised to keep the destructors virtual always. This is done to suppress the problems that may arise if inheritance is involved.

10. Global destructors execute in _____ order after main function is terminated
a) Sequential
b) Random
c) Reverse
d) Depending on priority

Answer

Answer: c [Reason:] The destructors are always called in reverse order no matter which destructor it is. This is done to ensure that all the resources are able to get free. And no resource is kept busy.

11. When is it advised to have user defined destructor?
a) When class contains some pointer to memory allocated in class
b) When a class contains static variables
c) When a class contains static functions
d) When a class is inheriting another class only

Answer

Answer: a [Reason:] This is always advised to have user defined destructor when pointers are involved in class. This is usually done to ensure that the memory, that was allocated dynamically, gets free after use and doesn’t cause memory leak.

12. Which among the following is correct for destructors concept?
a) Destructors can be overloaded
b) Destructors can have only one parameter at maximum
c) Destructors are always called after object goes out of scope
d) There can be only one destructor in a class

Answer

Answer: d [Reason:] This is so because the destructors can’t be overloaded. And the destructor must have the same name as that of class with a tilde symbol preceding the name of destructor. Hence there can be only one destructor in a class. Since more than one function with same name and signature can’t be present in same scope.

13. Which class destructor will be called first, when following code go out of scope?

class A{  };
class B{  };
class C: public B{  };
A a;
B b;
C c;

a) ~A()
b) ~B()
c) ~C()
d) ~B() and ~C()

Answer

Answer: c [Reason:] The constructor that would have created at last, its destructor will be called first when the code goes out of scope. This will help the program to manage the resources more efficiently.

14. When an object is passed to a function, its copy is made in the function and then:
a) The destructor of the copy is called when function is returned
b) The destructor is never called in this case
c) The destructor is called but it is always implicit
d) The destructor must be user defined

Answer

Answer: a [Reason:] When an object is passed to a function, its copy is made in the function. This copy acts as a real object till the function is live. When the function is returned, the copy’s destructor is called to free the resources held by it.

15. What happens when an object is passed by reference?
a) Destructor is not called
b) Destructor is called at end of function
c) Destructor is called when function is out of scope
d) Destructor is called when called explicitly

Answer

Answer: a [Reason:] The destructor is never called in this situation. The concept is that when an object is passed by reference to the function, the constructor is not called, but only the main object will be used. Hence no destructor will be called at end of function.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.