When is a memory allocated to a class?

Answers were Sorted based on User's Feedback



When is a memory allocated to a class?..

Answer / teginder

When instance of that class is creater by us

Is This Answer Correct ?    30 Yes 5 No

When is a memory allocated to a class?..

Answer / vineet makkar

The answer to this question lies in the basic difference
between
OBJECT & INSTANCE

INSTANCE : Refers to a reference of an object, it can be
null.

OBJECT: Actually pointing to the memory address of that
instance.

eg
Student stdnt; // Instance is created
Student stdnt = new Student; // Object is created

So, in short, memory is allocated to a class when the
object of the class is created using "new" keyword.

Is This Answer Correct ?    26 Yes 3 No

When is a memory allocated to a class?..

Answer / ramakrishna

A class is a template.As Teginder said,it will get
allocated memory when u create object of that class.

Is This Answer Correct ?    22 Yes 5 No

When is a memory allocated to a class?..

Answer / achal

when an object of that class is created and constructor
runs. memory is allocated in Stack (part of RAM)

Is This Answer Correct ?    13 Yes 3 No

When is a memory allocated to a class?..

Answer / anumohan

when instance of that class is created by creating object
to the class

Is This Answer Correct ?    11 Yes 3 No

When is a memory allocated to a class?..

Answer / namrata ahuja

when the object of that class is declared.

Is This Answer Correct ?    7 Yes 5 No

When is a memory allocated to a class?..

Answer / saurabh

when we create the data member of the class by using d syntax
class
{




static int a;
};
static int a;

Is This Answer Correct ?    3 Yes 1 No

When is a memory allocated to a class?..

Answer / x

It is allocated compile-time unless we are using new and
delete functions

Is This Answer Correct ?    3 Yes 1 No

When is a memory allocated to a class?..

Answer / b

when an object is intantiated from a class

Is This Answer Correct ?    0 Yes 0 No

When is a memory allocated to a class?..

Answer / sourav das

when object is created of that class then only memory is
allocated.with out object there is no Existence of class.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More OOPS Interview Questions

can we create and enter the data & hide files using programmes ?

2 Answers   Wipro,


What do you mean by public, private, protected and friendly?

3 Answers   CA,


What are the benefits of polymorphism?

0 Answers  


What is data binding in oops?

0 Answers  


#include <iostream> using namespace std; struct wow { int x; }; int main() { wow a; a.x = 22; int c = a.x; int *b = new int; cout << c; return 0; } option: No output 0 22 -(11) Will not compile

1 Answers   CTS, Wipro,






Can we create object of abstract class?

0 Answers  


what is difference between String s=new String("vali"); String s="vali"

1 Answers  


Explain polymorphism? What r the types of polymorphism? pls give examples?

4 Answers   HCL,


What is the full form of oops?

0 Answers  


#include <stdio.h> #include <alloc.h> #include <stdlib.h> #include <conio.h> void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.

0 Answers  


can you explain how to use JavaBean in Project

3 Answers   Infosys, Satyam,


1.what are two type of classe members called? 2.what is data hiding and data encapsulation? 3.how do you make a class member visible aouside its class? 4.what is the default visibility of a class data member? 5.what are the advantages of oop over the structured programing?

6 Answers  


Categories