top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

what is the size of an empty class in java and why?

+1 vote
1,774 views
what is the size of an empty class in java and why?
posted Feb 20, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Creating the object means creating the memory, therefore even though there are no
members in the class also, it will create a physical memory location of 1 byte and gets the address(object is reality)

answer Feb 27, 2015 by Amit Kumar Pandey
Hello Amit,
Hope you are doing well.

could you please send me any example for it.


Thanks.
Similar Questions
+2 votes

I would like to apply the Pool.map method to a member of a class. Here is a small example that shows what I would like to do:

from multiprocessing import Pool

class A(object):
 def __init__(self,x):
 self.value = x
 def fun(self,x):
 return self.value**x

l = range(10)

p = Pool(4)

op = p.map(A.fun,l)

using this with the normal map doesn't cause any problem

This fails because it says that the methods can't be pickled. (I assume it has something to do with the note in the documentation: "functionality within this package requires that the __main__ module be importable by the children.", which is obscure to me).

I would like to understand two things: why my code fails and when I can expect it to fail? what is a possible workaround?

+3 votes

Is there way to get list of instances of particular class through class itself? via metaclass or any other method?

If class is object is it possible to delete it? If it is possible then how instances of that class will behave?

...