Question
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
Posted under Object Oriented Programming
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What will be the output of the following code?
Similar Questions
Discover Related MCQs
Q. It is necessary to return the object if it was passed by reference to a function.
View solution
Q. How many objects can be passed to a function simultaneously?
View solution
Q. If an object is passed by address, will be constructor be called?
View solution
Q. Is it possible that an object of is passed to a function, and the function also have an object of same name?
View solution
Q. Passing an object using copy constructor and pass by value are same.
View solution
Q. What is reference to an object?
View solution
Q. Whenever an object is assigned to a variable or passed to a method, ________________
View solution
Q. Does use of object reference in assignment or passing means copy of the object is being used?
View solution
Q. Is there any explicit use of pointers in java that would be applicable to objects?
View solution
Q. Can a super class object give reference to a subclass method?
View solution
Q. If a reference variable is declared final then, _________________
View solution
Q. Which of the members are referred by this pointer usually (Java)?
View solution
Q. How to refer to method of nested class?
View solution
Q. How many objects can be referenced from same variables?
View solution
Q. Java handles memory dynamically and references are deleted as soon as they are out of scope.
View solution
Q. Invoking a method on a particular object is ____________ sending a message to that object.
View solution
Q. Can reference to an object be returned from a method?
View solution
Q. What does memory allocation for objects mean?
View solution
Q. Where is the memory allocated for the objects?
View solution
Q. When is the memory allocated for an object?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!