A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

1. In how many ways can an object be passed to a function?
a. 1
b. 2
c. 3
d. 4
View Answer Report Discuss Too Difficult!
Answer: (c).3

2. If an object is passed by value, ____________________
a. A new copy of object is created implicitly
b. The object itself is used
c. Address of the object is passed
d. A new object is created with new random values
View Answer Report Discuss Too Difficult!
Answer: (a).A new copy of object is created implicitly

3. Pass by address passes the address of object _________ and pass by reference passes the address of the object _________
a. Explicitly, explicitly
b. Implicitly, implicitly
c. Explicitly, Implicitly
d. Implicitly, explicitly
View Answer Report Discuss Too Difficult!
Answer: (c).Explicitly, Implicitly

4. If an object is passed by reference, the changes made in the function ___________
a. Are reflected to the main object of caller function too
b. Are reflected only in local scope of the called function
c. Are reflected to the copy of the object that is made during pass
d. Are reflected to caller function object and called function object also
View Answer Report Discuss Too Difficult!
Answer: (a).Are reflected to the main object of caller function too

5. Constructor function is not called when an object is passed to a function, will its destructor be called when its copy is destroyed?
a. Yes, depending on code
b. Yes, must be called
c. No, since no constructor was called
d. No, since same object gets used
View Answer Report Discuss Too Difficult!
Answer: (b).Yes, must be called

6. When an object is returned by a function, a _______________ is automatically created to hold the return value.
a. Temporary object
b. Virtual object
c. New object
d. Data member
View Answer Report Discuss Too Difficult!
Answer: (a).Temporary object

7. Is the destruction of temporary object safe (while returning object)?
a. Yes, the resources get free to use
b. Yes, other objects can use the memory space
c. No, unexpected side effects may occur
d. No, always gives rise to exceptions
View Answer Report Discuss Too Difficult!
Answer: (c).No, unexpected side effects may occur

8. How to overcome the problem arising due to destruction of temporary object?
a. Overloading insertion operator
b. Overriding functions can be used
c. Overloading parenthesis or returning object
d. Overloading assignment operator and defining copy constructor
View Answer Report Discuss Too Difficult!
Answer: (d).Overloading assignment operator and defining copy constructor

9. How many objects can be returned at once?
a. Only 1
b. Only 2
c. Only 16
d. As many as required
View Answer Report Discuss Too Difficult!
Answer: (a).Only 1

10. What will be the output of the following code?
Class A
{ 
 int i; 
 public : A(int n)
 { 
  i=n; cout<<”inside constructor ”;
 } 
 ~A()
 {
  cout<<”destroying  ”<<i;
 }
 void seti(int n)
 {
  i=n;
 }
 int geti()
 {
  return I;
 }
};
void t(A ob)
{ 
 cout<<”something ”;
}
int main()
{
 A a(1);
 t(a);
 cout<<”this is i in main ”;
 cout<<a.geti();
}
a. inside constructor something destroying 2this is i in main destroying 1
b. inside constructor something this is i in main destroying 1
c. inside constructor something destroying 2this is i in main
d. something destroying 2this is i in main destroying 1
View Answer Report Discuss Too Difficult!
Answer: (a).inside constructor something destroying 2this is i in main destroying 1

Page 1 of 15