Bloomberg LP Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

4 bytes for the pointer, 0 for static, static var is stored in static memory.

so 4 bytes total

- NewStart April 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

though the previous answer is correct, a catch is, it will be 8 bytes on 64bit machines

- Anonymous April 23, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

To be quite correct, if you use 64 bit compiler.
If you use 32 bit compiler running on 64 bit system, the result still will be 4.

- sergey.a.kabanov January 14, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

static variables are stored in the data segment or BSS of the process memory.

- Anonymous April 24, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

4

- Jay April 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is the size of the class and object always same ?Why is it so ?
If the class has static members, then these members are not stored in the object. Inspite of that will the class and object have the same size ?

- abhimanipal May 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I would say that for the class, the size of the static is taken into consideration, where as for the object you do not because static does not instantiate an object. So, in this case: size of the class would be 8 bytes and size of the object will be 4 bytes

- Aditya May 06, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

What do you mean y size of a class..? Unless and until you instantiate, the memory will not be allocated right? Just class does not make sense right? Please clarify.

- sandy May 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Yes, you are right. But, assuming that the object has been instantiated, the size of the class will be 8 bytes 'on paper' and 4 bytes for the object

- Anonymous May 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It should be the same = size of obj and class.. run it on a computer
also depends on 32 or 64 bit..because a pointer size is 4 byte on 32 bits only.

- Anonymous May 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

'Size of class' doesn't make sense because it's an abstract notion. If you want to calculate all the memory that relates to it you should also take the size of the code (hint: some member functions are generated by the compiler automatically... and then optimized). The total size of that memory is really implementation dependent (i.e. on the compiler).

Size of the object of that type (class A) depends on:
1. the platform (at least sizeof(void*))
2. the compiler (consider alignment settings). Though sizeof(A) is unlikely to be different from sizeof(void*).
For the sake of experiment, try sizeof(B) on your machine:
class B{
int i;
double d;
}

- Anonymous June 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Size of object should also take memory of this pointer (4 bytes)

- shankarjoshi48 July 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

tried on my 64bit windows, using VS2008, both of the sizes are 4 bytes...

- guest11 February 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

that is because your Vs2008 is 32 bit application!

- sergey.a.kabanov January 14, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

There is no such a thing as 'size of the class'.
Size can be of a data or of instructions.
In this case no instructions, only data which is stored in different places.
So size of object of a class will be equal to size of a pointer.
The static var will be stored in separate place.

- Leo March 10, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More