All 77 questions
What are the JVM memory areas, and how do the heap, stack, and Metaspace differ?
Asked in 8 of 335 interviews · last asked Nov 18 · Concept · Senior
Show answer
The JVM has a shared heap and method area, plus per-thread stacks, program counters, and native method stacks. The heap holds objects and arrays; stacks hold method calls, local variables, and temporary results. In HotSpot Java 8 and later, Metaspace stores class metadata in native memory as part of the method area.
- The heap is shared across threads; garbage collection reclaims unreachable objects.
- Each thread has its own Java stack; method calls create frames containing values and object references.
- Metaspace is outside the heap; class unloading can release its metadata.
- Deep calls can cause StackOverflowError; exhausted heap or Metaspace can cause OutOfMemoryError.
What the interviewer checks: The interviewer checks whether you understand what each area stores, which areas threads share, and how memory is released.
Other ways it was asked
- “How does the JVM memory model support garbage collection?”
- “How is memory structured inside the Java JVM?”
- “How does the JVM memory model work?”
How do value types and reference types differ, including how they are stored in memory?
Asked in 4 of 335 interviews · last asked Sep 10 · Concept · Junior
Show answer
In C#, value-type variables hold values; reference-type variables hold references to objects. Assignment copies the value or reference, so copied references share an object. Value types can live on the stack or inside heap objects. Reference-type objects live on the managed heap; their references can be stored on the stack or heap.
- Structs and enums are value types; classes, arrays, and strings are reference types.
- Value type does not mean stack storage. Storage depends on where the value is used.
- Boxing copies a value into an object on the managed heap.
- Copying a struct copies its fields; reference fields still point to the same objects.
What the interviewer checks: The interviewer checks whether you understand copying, shared objects, and why type alone does not determine storage.
Other ways it was asked
- “Do you know the difference between reference types and value types?”
- “Tell me a bit about the differences between value types and reference types.”
- “What is the difference between reference types and value types?”
In Java, when an ArrayList grows past capacity, what happens to its backing storage and what does that imply for existing element references and indices?
Asked in 3 of 335 interviews · last asked Oct 26 · Concept · Mid-level
Show answer
Java's ArrayList creates a larger backing array and copies the existing element references into it. The objects themselves are not copied, and references to them remain valid. Growth alone does not change element indices; inserting or removing elements can shift indices. The old array can be garbage collected once it is no longer referenced.
- The backing array is replaced, but the element objects stay the same.
- Appending preserves existing indices; insertion or removal can shift them.
- A resize takes linear time; appending takes constant time on average.
- The exact growth factor is an implementation detail, not an API guarantee.
What the interviewer checks: The interviewer is checking whether you distinguish the backing array, element references, and element indices.
Other ways it was asked
- “When an ArrayList grows past its current capacity, what exactly happens to its underlying array and the existing elements in memory?”
- “In Java, how does an ArrayList grow internally when it runs out of capacity, and what happens to existing elements during that growth?”
How is a doubly linked list node structured, and what memory overhead does it have versus an array?
Asked in 3 of 335 interviews · last asked Oct 26 · Concept · Senior
Show answer
A doubly linked list node stores a value and links to the previous and next nodes. Each node needs extra memory for these two links, plus possible allocation overhead and padding. In Java, LinkedList nodes hold three references: item, previous, and next. Compared with ArrayList, each element adds two link references and a separate node object's overhead.
- ArrayList stores element references in one backing array, with no separate node objects.
- A dynamic array may reserve unused capacity, which also costs memory.
- Exact overhead depends on reference size, object headers, alignment, and the runtime.
What the interviewer checks: The interviewer checks whether you can describe node fields and compare their memory cost with array storage.
Other ways it was asked
- “How is a doubly linked list node laid out in memory, what references or fields does it store, and what extra overhead does it have compared with a dynamic array?”
- “In Java, how is a LinkedList node structured, what references does it hold, and what extra memory cost does that imply per element versus an ArrayList?”
- “In Java, describe the memory layout of a doubly linked list node, what fields it stores, and what extra overhead you pay per element versus an ArrayList.”
Can you explain what pointers point to and how they are used in C and C++?
Asked in 3 of 335 interviews · last asked Oct 27 · Concept · Junior
Show answer
In C and C++, a pointer stores the address of an object or function, or a null value that points to nothing. Pointers let code access objects indirectly, modify a caller’s data, and work with arrays and dynamic memory. They are also used to build structures such as linked lists and trees.
- Use & to get an object’s address and * to access the object through a pointer.
- Only dereference pointers to live, valid objects; never dereference null, uninitialized, or dangling pointers.
- Pointer arithmetic stays within one array or one position past it; never dereference that past-the-end position.
- C commonly uses malloc and free; C++ usually prefers containers and smart pointers for dynamic memory.
Codeint value = 10; int *ptr = &value; // ptr points to value *ptr = 20; // value is now 20What the interviewer checks: The interviewer checks whether you understand addresses, indirect access, and safe use of memory.
Other ways it was asked
- “Can you explain pointers in C++, how they are used, and why they are useful?”
- “What are pointers in C++?”
- “What is a pointer in C++?”
What is virtual memory?
Asked in 3 of 335 interviews · last asked Oct 12 · Concept · Junior
Show answer
Virtual memory gives each process its own address space, separate from physical RAM. The operating system and hardware map virtual addresses to physical memory. This helps isolate processes and manage memory. It can also let programs use more memory than available RAM by moving less-used pages to disk.
- Virtual addresses are translated to physical addresses, usually through page tables.
- Memory protection helps prevent one process from accessing another process’s memory.
- A page fault may occur when a needed page is not in RAM.
- Frequent swapping between RAM and disk can slow programs down.
What the interviewer checks: The interviewer is checking whether you understand address translation, process isolation, and the role of disk-backed memory.
Other ways it was asked
- “What is virtual memory and why do we use it?”
What is the difference between shallow and deep copying, and when does it matter for nested objects?
Asked in 2 of 335 interviews · last asked Aug 14 · Concept · Junior
Show answer
A shallow copy creates a new outer object but keeps references to the same nested objects. A deep copy recursively copies nested objects, so changes to copied mutable data do not affect the original. This matters when editing nested lists or objects, such as during ML preprocessing.
- Changing a shared nested object affects both shallow copies.
- Replacing an item in the copied outer container does not change the original container.
- Deep copying usually takes more time and memory.
- In Python, use copy.copy() for shallow copying and copy.deepcopy() for deep copying.
Pythonimport copy original = [[1, 2], [3, 4]] shallow = copy.copy(original) deep = copy.deepcopy(original) shallow[0][0] = 99 print(original) # [[99, 2], [3, 4]] print(deep) # [[1, 2], [3, 4]]What the interviewer checks: The interviewer checks whether you understand shared references and can avoid unintended changes to nested data.
Other ways it was asked
- “What's the difference between a shallow copy and a deep copy, and why does it matter when copying arrays or objects?”
- “In Python, what's the practical difference between a shallow copy and a deep copy of a nested list, and when would it matter in an ML preprocessing pipeline?”
How do NumPy views and copies differ, and how can you check whether a slice shares memory?
Asked in 2 of 335 interviews · last asked Jun 3 · Concept · Mid-level
Show answer
A NumPy view shares its data with the original array, while a copy has separate data. Changing shared elements through a view also changes the original. Use np.shares_memory(original, sliced) to check for shared memory, and sliced.copy() when you need independent data.
- Basic slicing returns a view; integer-array and Boolean indexing return copies.
- np.shares_memory checks whether two arrays actually share memory.
- np.may_share_memory is conservative: True means sharing is possible, not certain.
- The .base attribute alone does not prove that two arrays share memory.
Pythonimport numpy as np original = np.arange(6) view = original[1:4] copy = view.copy() print(np.shares_memory(original, view)) # True print(np.shares_memory(original, copy)) # False view[0] = 99 print(original[1], copy[0]) # 99 1What the interviewer checks: The interviewer is checking whether you understand shared array data and can prevent accidental changes.
Other ways it was asked
- “In NumPy, how does a view differ from a copy, and how can you tell which one you got after slicing?”
- “In NumPy, what's the difference between a view and a copy, and how do you prevent accidental data mutation when slicing?”
- “How would you check in code whether a sliced NumPy array shares memory with the original array?”
What happens during boxing in C#, where is the object allocated, and how does it affect performance?
Asked in 2 of 335 interviews · last asked Aug 6 · Concept · Mid-level
Show answer
Boxing converts a value type, such as int, into an object containing a copy of its value. The boxed object is normally allocated on the managed heap. Frequent boxing adds allocation and copying costs and creates more work for the garbage collector.
- Passing an int to a method parameter of type object causes boxing.
- Changing the original value does not change the boxed copy.
- Generic collections, such as List<int>, avoid boxing when storing integers.
Codeint value = 42; object boxed = value; // Boxing: copies 42 into an object. value = 99; System.Console.WriteLine(boxed); // Prints 42.What the interviewer checks: The interviewer is checking whether you understand value copying, heap allocation, and the performance cost of boxing.
Other ways it was asked
- “What happens when an integer value is passed to a C# method that accepts an object?”
- “Where is the object allocated when a C# value type is passed as an object?”
- “What is boxing in C#, and how can frequent boxing affect application performance? Give a concrete example.”
What happens on a page fault? Walk me through it step by step.
Asked in 2 of 335 interviews · last asked Nov 2 · Concept · Mid-level
Other ways it was asked
- “Can you tell me what a page fault is?”
What are the stack and heap in memory, and why are they separate?
Asked in 2 of 335 interviews · last asked Nov 16 · Concept · Mid-level
Other ways it was asked
- “What’s the difference between stack and heap memory?”
How do std::vector reserve and resize differ in allocation, capacity, size, and element values?
Asked in 2 of 335 interviews · last asked Oct 4 · Concept · Junior
Show answer
reserve(n) can increase capacity, but leaves size and element values unchanged. It reallocates only when n exceeds capacity. resize(n) changes size, constructing added elements or destroying removed elements; it reallocates only if the new size exceeds capacity. Added elements are default-inserted, or copied from the value supplied to resize(n, value).
- Capacity counts available element slots; size counts live elements. Reserved slots are not valid elements to access.
- Reallocation moves or copies existing elements into new storage, invalidating all existing pointers, references, and iterators.
- Neither call reduces capacity. After growth, capacity may be greater than n.
- With the standard allocator, resize(n) adds zero-valued integers; class elements use their default constructors.
What the interviewer checks: The interviewer checks whether you distinguish allocated storage from live elements and understand construction, destruction, and reallocation.
Other ways it was asked
- “In C++, when you call reserve(n) on a vector, what exactly happens in memory if n is greater than the current capacity?”
- “In a vector, what's the difference between reserve(n) and resize(n) in terms of element construction, destruction, and observable size?”
- “What is the difference between reserve and resize on a std::vector, and what happens to size and element values in each case?”
What is a variable?
Asked in 2 of 335 interviews · last asked Nov 12 · Concept · Junior
Other ways it was asked
- “What does a variable mean?”
What are static variables?
Asked in 2 of 335 interviews · last asked Dec 4 · Concept · Junior
Show answer
In Java, static variables belong to a class, not to each object. All objects of that class share the same variable. You can access it through the class name without creating an object.
- Declared with the static keyword.
- Useful for shared state, such as a count of objects created.
- Static does not mean constant; the variable can change unless it is also final.
- Static variables are not automatically thread-safe; shared updates may need synchronization.
What the interviewer checks: The interviewer checks whether you understand class-level state versus separate state for each object.
Other ways it was asked
- “What are static variables in Java?”
What is stack memory?
Asked in 2 of 335 interviews · last asked Nov 10 · Concept · Junior
Other ways it was asked
- “What is stack memory in Java?”
What is the string pool?
Asked in 2 of 335 interviews · last asked Oct 30 · Concept · Junior
Other ways it was asked
- “Can you explain the string pool?”
Can you explain some page replacement algorithms?
Asked in 2 of 335 interviews · last asked Nov 2 · Concept · Junior
Other ways it was asked
- “Can you name an algorithm related to page replacement?”
How much memory does a string occupy in C#?
Asked once · last asked Sep 10 · Concept · Mid-level
Other ways it was asked
- “How much memory does a string field occupy within a C# object?”
How can you use one method for multiple value types in C# while avoiding boxing, rather than writing a separate method for each type?
Asked once · last asked Jan 28 · Concept · Senior
In a loop with a counter, what is the counter variable's scope, and how long does it remain in memory?
Asked once · last asked Mar 24 · Concept · Junior
What is copy-on-write in PHP, and how does it affect array and string behavior when values are passed to methods?
Asked once · last asked Mar 27 · Concept · Senior
How does Python represent list elements internally to support values of different types?
Asked once · last asked Mar 31 · Concept · Senior
When normalizing a product list, should you create a new object for each product or reuse the original product object, and why?
Asked once · last asked Apr 28 · Concept · Mid-level
What is the default stack size for a .NET thread?
Asked once · last asked May 7 · Concept · Mid-level
Could you explain the differences between stack and heap allocation in C++, and how RAII helps manage resources safely?
Asked once · last asked Jun 15 · Concept · Junior
What is the difference between creating a string with new and using a string literal in Java?
Asked once · last asked Jul 16 · Concept · Mid-level
How would you explain copy-on-write in Swift for Array and Data, and what practical steps help avoid unintended copies for performance-critical code?
Asked once · last asked Aug 4 · Concept · Senior
In a typical function call, what's the difference between passing a parameter by value versus by reference?
Asked once · last asked Aug 14 · Concept · Junior
How do mutability and immutability work under the hood in Python?
Asked once · last asked Aug 25 · Concept · Senior
Other ways it was asked
- “How does mutability and immutability work under the hood in Python?”
Where is a byte field, such as age, stored within a .NET User object?
Asked once · last asked Sep 10 · Concept · Mid-level
In .NET, is where a value is stored determined by its type, or by other factors?
Asked once · last asked Sep 10 · Concept · Mid-level
In C#, what happens to memory and parameter passing when a method is called with two int variables?
Asked once · last asked Sep 10 · Concept · Mid-level
How does .NET determine the structure of data stored in an object's memory?
Asked once · last asked Sep 10 · Concept · Senior
Why should you account for string memory usage when estimating the size of a class instance?
Asked once · last asked Sep 10 · Concept · Mid-level
In C#, what happens to memory when a struct contains a string field?
Asked once · last asked Sep 10 · Concept · Senior
In C++, in a hash map that uses separate chaining, what exactly is stored in the bucket array and how are the key value pairs laid out in memory?
Asked once · last asked Sep 21 · Concept · Mid-level
In C++, what are the differences between std::vector and std::deque, including memory layout and push/pop complexity at the front and back?
Asked once · last asked Oct 4 · Concept · Mid-level
In a std::vector, what happens to the addresses of existing elements after a reallocation, and which operations can trigger that reallocation?
Asked once · last asked Oct 4 · Concept · Senior
In an unordered_map, what exactly invalidates iterators, and does a rehash invalidate references and pointers to elements as well?
Asked once · last asked Oct 4 · Concept · Senior
How do doubly linked list pointers support splicing and reordering without moving or copying elements?
Asked once · last asked Oct 4 · Concept · Junior
Other ways it was asked
- “In a doubly linked list, what pointers does each node typically store, and which operations can be done without moving existing nodes in memory?”
- “In a doubly linked list, which operations can splice or reorder elements by only relinking pointers, with no element moves or copies, and what does that require about the nodes involved?”
When would you decide that iterative loops are safer than recursion?
Asked once · last asked Oct 6 · Concept · Junior
Could you differentiate between structures and unions with respect to memory?
Asked once · last asked Jan 22 · Concept · Junior
How are mutable and immutable objects represented and managed in Python memory?
Asked once · last asked Aug 25 · Concept · Senior
What happens when you assign one memory struct to another memory struct in Solidity?
Asked once · last asked Nov 13 · Concept · Senior
Other ways it was asked
- “What happens when you assign a memory struct to a storage struct in Solidity?”
- “What happens when you assign one storage struct to another storage struct in Solidity?”
What is the difference between mutable and immutable objects in terms of memory allocation?
Asked once · last asked Jun 11 · Concept · Mid-level
Why might you use separate pointers to traverse an array instead of using the pointers that hold its base addresses?
Asked once · last asked Nov 18 · Concept · Junior
What is the difference between new/delete and malloc/free in C++?
Asked once · last asked Oct 30 · Concept · Mid-level
What is the difference between storage, calldata, and memory?
Asked once · last asked Nov 2 · Concept · Mid-level
If an integer initialized to 512 is modified through a character pointer, what determines the value subsequently read from the integer?
Asked once · last asked Nov 5 · Concept · Senior
Other ways it was asked
- “How does modifying an integer through a character pointer affect the value read from the integer, and what determines the result?”
Why can modifying a dictionary referenced by a variable also change the dictionary stored in a list?
Asked once · last asked Nov 9 · Concept · Junior
What's the difference between storage and memory when you define a struct in Solidity?
Asked once · last asked Nov 13 · Concept · Senior
What is transient storage in Solidity, and when would you use it?
Asked once · last asked Nov 13 · Concept · Senior
Which objects are allocated on the large object heap, and what performance problems can they cause?
Asked once · last asked Nov 17 · Concept · Senior
How do Python sets and dictionaries differ in memory usage?
Asked once · last asked Nov 19 · Concept · Mid-level
Why does a Python dictionary leave some storage unused and grow when it is about 70% full?
Asked once · last asked Nov 19 · Concept · Senior
What is the difference between call by value and call by reference?
Asked once · last asked Aug 10 · Concept · Junior
What is a reference in Java?
Asked once · last asked Oct 8 · Concept · Junior
Other ways it was asked
- “Can you give an example of a reference in Java?”
What is the process called when a C# value type is converted to an object or another reference type?
Asked once · last asked Jan 28 · Concept · Junior
Are .NET references the same as pointers?
Asked once · last asked May 7 · Concept · Junior
Where is a static variable in C stored, and how does its storage differ from heap-allocated memory?
Asked once · last asked Jun 29 · Concept · Junior
What is the Java heap, and how is it used?
Asked once · last asked Jul 16 · Concept · Junior
What is thrashing?
Asked once · last asked Aug 6 · Concept · Junior
What is an MMU?
Asked once · last asked Aug 6 · Concept · Junior
Can you explain what a Windows page file is?
Asked once · last asked Aug 9 · Concept · Junior
What is the function of a pointer?
Asked once · last asked Sep 2 · Concept · Junior
What is heap memory?
Asked once · last asked Sep 4 · Concept · Junior
Why do people say that a variable is stored on the stack in .NET?
Asked once · last asked Sep 10 · Concept · Mid-level
How are pointers related to linked lists?
Asked once · last asked Oct 6 · Concept · Junior
What causes a stack overflow error?
Asked once · last asked Oct 16 · Concept · Mid-level
What happens behind the scenes when a function is called?
Asked once · last asked Jan 22 · Concept · Junior
What happens when an argument is passed by reference, and how does the function access the caller's variable?
Asked once · last asked Jan 22 · Concept · Junior
In C, what does the asterisk in a declaration such as `int *rb` mean?
Asked once · last asked Nov 18 · Concept · Junior
Other ways it was asked
- “In C, what does the asterisk in a declaration such as `int *rb` mean, and what do assignments like `pb = rb` and `pc = rc` do?”
What happens when you create a new object in Java?
Asked once · last asked Nov 10 · Concept · Junior
Why might an algorithm create a new array on each iteration?
Asked once · last asked Nov 15 · Concept · Mid-level
What is a page table?
Asked once · last asked Nov 18 · Concept · Junior
Why might you keep an array’s original base address if its elements remain unchanged?
Asked once · last asked Nov 18 · Concept · Junior
How do pointers such as `rb` and `pb` relate to the elements of an original array?
Asked once · last asked Nov 18 · Concept · Junior
More Operating Systems interview questions
- All Operating Systems interview questions
- Garbage Collection and Resource Management Interview Questions
- Memory Leaks and Performance Troubleshooting Interview Questions
- Large Data Processing and Out-of-memory Interview Questions
How this list is made
Every question here was asked by a real interviewer in a real job interview that a candidate ran MeetAssist in. After the call, the interviewer's questions are pulled from the transcript. Practice sessions, tests, exams and anything that was not a job interview are dropped.
Questions are rewritten so they make sense on their own: names of people, employers and clients are removed, and speech-to-text mistakes are fixed. Small talk, logistics and questions about one candidate's own résumé are left out. Rephrasings of the same question are merged, and the count is the number of different interviews it came up in.
The interviews come from candidates who use MeetAssist, so they lean towards software, data and AI roles: the shares describe these interviews, not every Operating Systems interview. Answers to the most asked questions are written and checked by an editor; a "common mistake" is shown only when reviews of real answers in these interviews show it, with the count.
335 interviews, 268 candidates, Dec 2025 to Nov 2026. Updated every month with new interviews.
Or add the Chrome extension