FlexTrade Interview Question
Software Engineer / Developersvery good..in general term of answers.
But they again, the interview needs to be specific..or you need to be specific to 'show him up'. There is a difference in size of the class if the order of the float and doubles are rearrange. the answer can also easily be 24 instead of 16. Try it. It has to do with class and struct paddings alignment. Also if you add pointers to it, then you also have to pay attention to if the machine is 32-bit or 64-bit.
Man, these interviewers needs to be specific or they just don't 100% know their stuff
The reason interviews in most companies are not specific is because they want the candidate to come up with assumptions and solve the questions.
The first answer was correct and was simple
The second answer showed more in depth analysis - implying the candidate goes into details.
Generally size of float is 4 bytes and size of double is 8 bytes. so Size of object will be 16 bytes.
- Anonymous March 30, 2010if a static double, then size will be 8 bytes because static variables are not allocated on stack. they are global for class.
If all member variables are static then size will be 1 byte not zero because an object should have an address to show its existence....