| Author |
Plz . Answer
|
faisal usmani
Ranch Hand
Joined: Jan 14, 2006
Posts: 139
|
|
What is the size of an object in Java , if the class has no member variables or member functions . Eg :- class ABC { } What will be the size of object of class ABC if we do ABC ob1 = new ABC(); Do we have a sizeof operator in Java as we have in C/C++
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24061
|
|
The actual amount of memory that an object uses depends on the Java implementation -- i.e., it's not specified by the Java VM specification or the Java Language specification. The number is never directly useful in any program -- no Java language function or construct depends on the memory image size of an object. The precise answer may well vary by JVM vendor, by platform, and even by version. That said, for Sun's JVMs a good rule of thumb is 16 bytes for an object, plus four bytes for each member -- except doubles and longs, which are 8 bytes each. Note: have a look at this when you have time.
|
[Jess in Action][AskingGoodQuestions]
|
 |
faisal usmani
Ranch Hand
Joined: Jan 14, 2006
Posts: 139
|
|
Thanks sir I got the point
|
 |
 |
|
|
subject: Plz . Answer
|
|
|