Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How can we find size of the object ?

Answers were Sorted based on User's Feedback



How can we find size of the object ?..

Answer / niranjanravi

there is no sizeOf() in java to find the size of the object

Is This Answer Correct ?    8 Yes 4 No

How can we find size of the object ?..

Answer / m!r@

public class FindSizeOfObject{
public static void main(String[] args) throws Exception{

Runtime obj = Runtime.getRuntime();
System.out.println(obj.totalMemory() - obj.freeMemory());
}
}

Is This Answer Correct ?    1 Yes 1 No

How can we find size of the object ?..

Answer / lachha g

you can use Instrumentation class.

use long getObjectSize(Object objectToSize) method.
It returns amount of storage consumed by the specified object.
package Test;

import java.lang.instrument.Instrumentation;

public class ObjectSize {
private int x;
private int y;

ObjectSize(int x, int y){
this.x=x;
this.y=y;
}


public static void main(String [] args) {
ObjectSize obj= new ObjectSize(2,4);
System.out.println(Test.getObjectSize(obj));
}
}
class Test {
private static Instrumentation instrumentation;

public static void premain(String args, Instrumentation inst) {
instrumentation = inst;
}

public static long getObjectSize(Object o) {
return instrumentation.getObjectSize(o);
}
}

Is This Answer Correct ?    0 Yes 0 No

How can we find size of the object ?..

Answer / sitaram

we don't have any method for to identify the size of object
in java.

Is This Answer Correct ?    0 Yes 2 No

How can we find size of the object ?..

Answer / suvarna

getObjectSize(Object objectToSize)
Returns an implementation-specific approximation
of the amount of storage consumed by the specified object.

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More Core Java Interview Questions

Which non-unicode letter characters may be used as the first character of an identifier?

0 Answers  


For which statements we use a label?

3 Answers   Wipro,


Why pass by reference is not possible in java?

0 Answers  


write java code to print second max number in the array

12 Answers   Huawei, IBAB,


What are parent methods and how can you call them?

2 Answers  


What class allows you to read objects directly from a stream?

0 Answers  


What is meant by null and void?

0 Answers  


What is user defined exception in Java?

0 Answers   TCS,


What is difference between ++ I and I ++ in java?

0 Answers  


What are the three parts of a lambda expression?

0 Answers  


What restrictions are placed on method overloading and method overriding?

5 Answers  


What is vector?

0 Answers  


Categories