When is an object created and what is its lifetime?
Answers were Sorted based on User's Feedback
Answer / apurva jain
Object is created when constructor has to be invoked or
when have to access the class.Its Lifetime is throughout
the Execution of that Class.
Is This Answer Correct ? | 30 Yes | 8 No |
Answer / nikhil
global scope,if created outside class n local scope if
created inside a class......
Is This Answer Correct ? | 3 Yes | 2 No |
Answer / alok pandey
When the constructor called then object created thus while
the programme execute till life of object
Is This Answer Correct ? | 2 Yes | 2 No |
Answer / yathirajulu
whenever developer is required, and the life-time is when we
assinging null or close the program(application).
Is This Answer Correct ? | 2 Yes | 14 No |
#include <iostream> using namespace std; int main() { int a = 3; int c[5][5]; for (int x=0;x<5;x++) { for (int y=0;y<5;y++) { c[x][y] = x*y; } } cout << c[a][2]; }
What is difference between polymorphism and inheritance?
How to Increment the value of the empid E001 for each and every employee by using the programe?
What is advantage of inheritance?
suppose A is a base class and B is the derved class. Both have a method foo which is defined as a virtual method in the base class. You have a pointer of classs B and you typecast it to A. Now when you call pointer->foo, which method gets called? The next part of the question is, how does the compiler know which method to call?
What are the four main oops concepts?
Can we create object of class with private constructor?
What are the 3 principles of oop?
How would you stop a class from class from being derived or inherited.
what is the need of abstraction? what is abstraction?what is the abstraction for stack?
What is oops concept with example?
What is new keyword in oops?