prasanjeit
java memory allocation for member variables and member functions
2 Answer(s)      3 years ago
Posted in : Java Beginners

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

Ads

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
Java memory allocation
Java memory allocation  How does Java allocate stack and heap memory
Advertisements
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
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
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
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
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
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
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
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
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
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
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
Java memory leak
Java memory leak  What is memory leak
Creating a memory leak with Java
Creating a memory leak with Java  Creating a memory leak with Java
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
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
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) 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 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
Memory - Java Beginners
Memory management in Java  Where are these Heap and Stack? Is there size fixed? what is core area in memory
Java - Declaring variables in for loops
Java - Declaring variables in for loops  Java - Declaring variables in for loops
Java Substituting Variables
Java Substituting Variables  Java Substituting Variables
Variables In Java
This tutorial demonstrates you about the variables and their types in java
transient variables in java
transient variables in java  hello, What are transient variables in java?   hii, Transient variables are variable that cannot be serialized

Ads

Advertisement