java memory allocation for member variables and member functions

java memory allocation for member variables and member functions

Suppose I have created a class named test with a member function name fun() that has three variables a=5,b=6.My questions are 1>When will the memory be allotted for these variables at run time or at compile time??? 2>Suppose i do not create a main method then will the memory be allotted for member function fun() and its variables?? 3>suppose i write a main method and from it i create an object q of test class then when shall the memory be allotted for function fun() and its variables ?? 4>When does java set default values of variables declared in a class that has not been assigned with any value??

View Answers

August 4, 2013 at 7:05 PM

off course at running time .. how means explanation is given bellow... see there are two stage while execution . 1 - is converting of the source code into byte code this is called as the compilation and during this no memory allocation takes place . and now 2- is the converting of the byte code to machine level i.e binary code for understanding to jvm purpose . this is called as the running phase during this phase jvm will allocate the memory for the data members .


August 4, 2013 at 8:22 PM

Thanks for your answer but can you answer my 4> question ??

Ads









Related Tutorials/Questions & Answers:
java memory allocation for member variables and member functions
java memory allocation for member variables and member functions  ...() that has three variables a=5,b=6.My questions are 1>When will the memory be allotted... not create a main method then will the memory be allotted for member function fun
Member Classes, Inner Nested Classes in java
Member Classes        Member classes are defined within the body of a class. We can use member classes anywhere within the body of the containing class. We declare member classes
Advertisements
ModuleNotFoundError: No module named 'member'
ModuleNotFoundError: No module named 'member'  Hi, My Python... 'member' How to remove the ModuleNotFoundError: No module named 'member'... to install padas library. You can install member python with following command
ModuleNotFoundError: No module named 'member'
ModuleNotFoundError: No module named 'member'  Hi, My Python... 'member' How to remove the ModuleNotFoundError: No module named 'member'... to install padas library. You can install member python with following command
call to a member function
call to a member function  While uploading the data on server i am getting following error... call to a member function children
memory allocation
memory allocation   class Bird { { System.out.print("b1 "); } public Bird() { System.out.print("b2 "); } } class Raptor extends Bird { static... of execution of statement ? memory allocation ?  The code uses static
Member Classes
Member Classes       The class defined in the body of a class is called a member class. Member classes can also use instances of the same class without explicit
memory allocation
memory allocation  If we assign memory malloc(5) and access more than the assigned memory then what will happen? 1.segmentation error 2.memory leak 3.program will not compile 4.Your view
Controlling Java Heap Size Memory Allocation
Controlling Java Heap Size Memory Allocation  Hi, Tell me about Controlling Java Heap Size Memory Allocation? I have to run java program from console and allocate 2GB of RAM to Java Heap Size. Thanks   Hi, You can
Memory Allocation
Memory Allocation  What Is The Order Of Execution Of Statement 1) Statement Enclosed in {}. 2) Static 3) Public Static Void Main()   When jvm loads a class, static block is executed first, then main method. And at last
What is a local, member and a class variable?
What is a local, member and a class variable?   Hi, What is a local, member and a class variable? thanks
ModuleNotFoundError: No module named 'zds-member'
ModuleNotFoundError: No module named 'zds-member'  Hi, My Python... 'zds-member' How to remove the ModuleNotFoundError: No module named 'zds-member' error? Thanks   Hi, In your python environment you
What does it mean that a class or member is final?
What does it mean that a class or member is final?   hi, What does it mean that a class or member is final? Thanks
ModuleNotFoundError: No module named 'aws-member-accnt-manager'
ModuleNotFoundError: No module named 'aws-member-accnt-manager'  Hi...: No module named 'aws-member-accnt-manager' How to remove the ModuleNotFoundError: No module named 'aws-member-accnt-manager' error? Thanks  
ModuleNotFoundError: No module named 'aws-member-accnt-manager'
ModuleNotFoundError: No module named 'aws-member-accnt-manager'  Hi...: No module named 'aws-member-accnt-manager' How to remove the ModuleNotFoundError: No module named 'aws-member-accnt-manager' error? Thanks  
ModuleNotFoundError: No module named 'django-wechat-member'
ModuleNotFoundError: No module named 'django-wechat-member'  Hi...: No module named 'django-wechat-member' How to remove the ModuleNotFoundError: No module named 'django-wechat-member' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-wechat-member'
ModuleNotFoundError: No module named 'django-wechat-member'  Hi...: No module named 'django-wechat-member' How to remove the ModuleNotFoundError: No module named 'django-wechat-member' error? Thanks   Hi
ModuleNotFoundError: No module named 'openstack-member-spammer-estimator'
ModuleNotFoundError: No module named 'openstack-member-spammer-estimator' ...: ModuleNotFoundError: No module named 'openstack-member-spammer-estimator' How to remove the ModuleNotFoundError: No module named 'openstack-member-spammer-estimator
ModuleNotFoundError: No module named 'solution-efe-client-member'
ModuleNotFoundError: No module named 'solution-efe-client-member'  Hi...: No module named 'solution-efe-client-member' How to remove the ModuleNotFoundError: No module named 'solution-efe-client-member' error? Thanks
ModuleNotFoundError: No module named 'solution-efe-client-member'
ModuleNotFoundError: No module named 'solution-efe-client-member'  Hi...: No module named 'solution-efe-client-member' How to remove the ModuleNotFoundError: No module named 'solution-efe-client-member' error? Thanks
ModuleNotFoundError: No module named 'aws-member-accnt-manager'
ModuleNotFoundError: No module named 'aws-member-accnt-manager'  Hi...: No module named 'aws-member-accnt-manager' How to remove the ModuleNotFoundError: No module named 'aws-member-accnt-manager' error? Thanks  
ModuleNotFoundError: No module named 'django-wechat-member'
ModuleNotFoundError: No module named 'django-wechat-member'  Hi...: No module named 'django-wechat-member' How to remove the ModuleNotFoundError: No module named 'django-wechat-member' error? Thanks   Hi
How to access sub class member using super class object
How to access sub class member using super class object  class A{ } class B extends A{ int b=1; } class Test{ public static void main(String args[]) { what to do here to access sub class variable b using super class object
making consistency of data member in the whole programme without using static keyword
making consistency of data member in the whole programme without using static keyword  In the below programme i use one boolean variable named check , which is being accessed inside main function by two objects of Tst1 and Test2
Variables in Java
Variable in Java In this section you will learn about variables in java. First we should know, what is variable? variable is a location in the memory where values persist. In Java, all variable must be declared first before
Variables in Java
variables) Java Primitive Data Types Data Type Description... 0.0d In this section, you will learn about Java variables. A variable... when a program executes. The Java contains the following types of variables
Java - Declaring variables in for loops
Java - Declaring variables in for loops  Java - Declaring variables in for loops
Access Modifiers
and accessibility of a class, member variables and methods. Java provides... with the member variables and methods to specify their accessibility. ... makes a member of the class available to all classes in the same package
Java memory leak
Java memory leak  What is memory leak
Variables In Java
This tutorial demonstrates you about the variables and their types in java
Java Substituting Variables
Java Substituting Variables  Java Substituting Variables

Ads