Interview Question: Class vs. Structure

As a part of my job, I interview potential candidates for jobs, and one of the standard questions I ask is ‘What is the difference between a class and a structure?’, and I sometimes am surprised with the kind of answers I get.

So, I decided, I should get some of these proper QnA’s for interview questions, and post them as a series.

  Class Structure
Type Reference Value
Performance Slower Faster
Storage Stack Heap (requires cleanup by GC)
Optimal size > 16 bytes < 16 bytes
Default protection level Private Public
Default Constructor Present Absent
Is Immutable No Yes

Misc references :

Leave a Reply