File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Can anybody tell me...???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Can anybody tell me...????" Watch "Can anybody tell me...????" New topic

Can anybody tell me...????

Aftab Ahmed
Ranch Hand

Joined: Nov 22, 2000
Posts: 42
Hi Frndz,
can someone tell me what is Compile-time constant. and also mentioned compile-time constant (if posible).
aftab abbasi

Keep Simlling
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3635
Compile time constant means just that! A thing which is known to be constant at the time the program is compiled.
For eg, final int i = 10; 'i' is a compile time constant because the compiler knows that as it is final, it will never ever change. On the other hand, int i = 10; is not a constant because, the value of i can be changed anywhere in the program.
Get Certified, Guaranteed!
(Now Revised for the new Pattern)

Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
George Toronto
Ranch Hand

Joined: Dec 30, 2000
Posts: 78
H, Aftab
I think your question is over the Core section, but I glad to help you understand the mechanism of allocation of JVM.
JVM uses two seperate heaps to handle the memory allocation. One is responsible for static allocation and another is for dynamic allocation. when you define a final varible, it is allocated in to a heap which cannot clloected by gc. So it stays in memorey until the application is over. All class definitions, the Constant Pool, and method tables are kept in a nongarbage collected heap.
The second heap is split into two areas that grow in opposite directions. One area is used to hold object instances, and the other contains "handles" to those instances. The runtime image of fields and variables in your Java application that reference object instances do not actually contain pointers to those objects. They contain pointers to a special, fixed-size, heap-based memory object called a handle. The handle is a structure that contains two pointers: one to the object's method table and the other to the actual object instance. The advantage to this layout is that the handles never move in memory, so there is never a need to keep track of which variables point to which objects when updating pointers after compacting. You simply update the pointer value of the handle structure.
So , now, you can understand what is compil-time constant, what is runtime varible. In fact, in my understanding, the runtime varible is not a dynamic one since its handler can not be changed during the application lifecycle.
The above is just my view and just as reference, if there are wrong sections, plz point out.Thanks
I agree. Here's the link:
subject: Can anybody tell me...????
jQuery in Action, 3rd edition