Objects and Classes Mcqs
Our collections of Multiple choice questions and answers focuses on study of Objects and Classes in OOP. These questions are chosen from a collection of most authoritative and best reference books on OOP. Our aim is to prepare an individual for competitive exams like NTS, Web Developer | IOS Developer | Game Developer | Software House interviews and jobs, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Objects and Classes of OOP comprehensively.
Object Oriented Programming Mcqs
- Access Specifiers Mcqs
- Builtin Classes Mcqs
- Class Members Mcqs
- Concept and Features Mcqs
- Constructors and Destructors Mcqs
- Exception Handling Mcqs
- Inheritance and its Types Mcqs
- Member Functions Mcqs
- Memory Allocation and Variable Scope Mcqs
- Objects and Classes Mcqs
- Objects and Pointers Mcqs
- Overloading Mcqs
Computer MCQS
Sciences MCQS
2.
If an object is passed by value, ____________________
A new copy of object is created implicitly
The object itself is used
Address of the object is passed
A new object is created with new random values
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
3.
Pass by address passes the address of object _________ and pass by reference passes the address of the object _________
Explicitly, explicitly
Implicitly, implicitly
Explicitly, Implicitly
Implicitly, explicitly
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
4.
If an object is passed by reference, the changes made in the function ___________
Are reflected to the main object of caller function too
Are reflected only in local scope of the called function
Are reflected to the copy of the object that is made during pass
Are reflected to caller function object and called function object also
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
5.
Constructor function is not called when an object is passed to a function, will its destructor be called when its copy is destroyed?
Yes, depending on code
Yes, must be called
No, since no constructor was called
No, since same object gets used
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
6.
When an object is returned by a function, a _______________ is automatically created to hold the return value.
Temporary object
Virtual object
New object
Data member
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
7.
Is the destruction of temporary object safe (while returning object)?
Yes, the resources get free to use
Yes, other objects can use the memory space
No, unexpected side effects may occur
No, always gives rise to exceptions
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
8.
How to overcome the problem arising due to destruction of temporary object?
Overloading insertion operator
Overriding functions can be used
Overloading parenthesis or returning object
Overloading assignment operator and defining copy constructor
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
9.
How many objects can be returned at once?
Only 1
Only 2
Only 16
As many as required
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();
}
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();
}
Inside constructor something destroying 2this is i in main destroying 1
Inside constructor something this is i in main destroying 1
Inside constructor something destroying 2this is i in main
Something destroying 2this is i in main destroying 1
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
11.
It is necessary to return the object if it was passed by reference to a function.
Yes, since the object must be same in caller function
Yes, since the caller function needs to reflect the changes
No, the changes are made automatically
No, the changes are made explicitly
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
12.
How many objects can be passed to a function simultaneously?
Only 1
Only an array
Only 1 or an array
As many as required
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
13.
If an object is passed by address, will be constructor be called?
Yes, to allocate the memory
Yes, to initialize the members
No, values are copied
No, temporary object is created
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
14.
Is it possible that an object of is passed to a function, and the function also have an object of same name?
No, Duplicate declaration is not allowed
No, 2 objects will be created
Yes, Scopes are different
Yes, life span is different
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
15.
What is reference to an object?
It is address of an object
It is address of where the variables and methods of object are stored
It is pointer having address of an object
It is address of only variables and not the methods of an object
Answer & Solution
No Solution for this Answer..! Report or Discus this Question