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 ??









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
Nonaccess Member Modifiers - Java Beginners
Nonaccess Member Modifiers  what is Nonaccess Member Modifiers give... be variously applied to different Java elements. An abstract class cannot... information. http://wwww.roseindia.net/java/master-java/abstract-class.shtml
Advertisements
Java memory allocation
Java memory allocation  How does Java allocate stack and heap memory
Java Memory allocation - Java Interview Questions
Java Memory allocation  By default what is the memory allocation size for a single class? How the memory is allocated? Based on what procedure
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
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
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   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
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
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
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
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
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 '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
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
In data structure in java how to parse the given string and counts the member of character that match the given data?
In data structure in java how to parse the given string and counts the member of character that match the given data?  Design a parser that parse the given string and counts the member of character that match the given data.using
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
java - Java Beginners
the memory allocation will be done to class variables,instance variables ,member varaiables in java   Hi Friend, Please visit the following link: http://www.roseindia.net/java/java-virtual-machine.shtml Hope
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
Variables in Java       In this section, you will learn about Java variables... is stored when a program executes. The Java contains the following types of variables
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... of variable in java, they are as follows :ADS_TO_REPLACE_2 Instance Variables
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
Variables in Java
variables)ADS_TO_REPLACE_1 Java Primitive Data Types Data Type... variables. A variable refers to the memory location that holds values like: numbers... in addition to variables in Java statement. While writing a source code
Java Variables - Java Beginners
Java Variables  Hi, I had a small doubt. What are Object Reference variables in java..What actually they do.. And What actually an Object Reference variable will contain? As there are no pointers in Java, what are object
Java Variables - Java Beginners
Java Variables  Hi, I had a small doubt. What are Object Reference variables in java..What actually they do.. And What actually an Object Reference variable will contain? As there are no pointers in Java, what are object
Java - Declaring variables in for loops
Java - Declaring variables in for loops  Java - Declaring variables in for loops
Variables In Java
This tutorial demonstrates you about the variables and their types in java
Java Substituting Variables
Java Substituting Variables  Java Substituting Variables
transient variables in java
transient variables in java  hello, What are transient variables in java?   hii,ADS_TO_REPLACE_1 Transient variables are variable that cannot be serialized
Java memory leak
Java memory leak  What is memory leak
Static & Instance variables in java
Static & Instance variables in java  What are the Difference between Static & Instance variables in java
yarn.scheduler.minimum-allocation-mb
yarn.scheduler.minimum-allocation-mb  Hi, I am submitting an Java... as it outside max allowed. yarn.scheduler.minimum-allocation-mb How to solve... it: --driver-memory 1665m \ --driver-cores 2 \ --executor-memory 4g thanks
Creating a memory leak with Java
Creating a memory leak with Java  Creating a memory leak with Java
instance variables - Java Beginners
instance variables  instance variables
java protected variables
java protected variables   Can we inherit the Java Protected variable..?   of course you can. But I think what you mean is "override"? Is tha so? There are some restriction
PHP Mutator Accessor
PHP Mutator and Accessor Methods: In object-oriented programming, the mutator method (also called "setter") is used to initialize the member variables of a class. According to the encapsulation principle the variables
Variables
Variables  What are the difference between Static variables, instance variables and local variables
Java memory optimization
Java memory optimization  When you think about optimization, what..., You can use memory dump and then analyze it to find the process/java code in your program which is using large amount of memory. Ideally java should garbage
There is insufficient memory for the Java Runtime Environment to continue.
There is insufficient memory for the Java Runtime Environment to continue.  Hi, I am getting error "There is insufficient memory for the Java...) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory
interface variables - Java Beginners
interface variables  why interface variables are final? explain me with good program example?? i knw why the variable is static but,i dont knw why it is final by default? thanks in advance

Ads