As we all know that java uses the following data types
byte Occupy 8 bits in memory
short Occupy 16 bits in memory
int Occupy 32 bits in memory
long
The in-memory size of the object depends on the architecture, mainly on whether the VM is 32 or 64-bit. The actual VM implementation also matters.
For each object, you need space for its object header (typically 2*8 bytes on 64-bit VMs), its fields (extra space for alignment depending on the VM implementation). The final space is then rounded up to the nearest multiple of the word size.