9 Multi-Language Programming interview questions and answers
Questions that come up in technical interviews, with model answers. Try answering out loud first, then open the question to compare.
Q01Which of Java, C++, Python, JavaScript and Go are compiled, and which are interpreted?FundamentalsBasic
C++ and Go compile ahead of time to native machine code. Java compiles to bytecode that the JVM runs, using a JIT compiler for hot code.
CPython compiles to bytecode and interprets it. JavaScript engines such as V8 JIT-compile it. This affects startup time, speed and how you deploy.
Q02What is the difference between static and dynamic typing?TypesBasic
With static typing, types are checked before the program runs (Java, C++, Go), so many errors are caught early and tools can help more.
With dynamic typing, types are checked at run time (Python, JavaScript), which is quicker to write but surfaces errors later. TypeScript and Python type hints add optional static checks.
Q03What is the difference between the stack and the heap?MemoryIntermediate
The stack holds function call frames and local values. It is fast, freed automatically when a function returns, and limited in size.
The heap holds data that must outlive a function call. It is freed by a garbage collector in Java, Go, Python and JavaScript, and by RAII and smart pointers in C++. Go's compiler decides which values escape to the heap.
Q04How does garbage collection compare with manual memory management?MemoryIntermediate
A garbage collector frees objects that nothing references any more: generational collectors in Java, reference counting plus a cycle collector in CPython, a concurrent mark-and-sweep collector in Go. It costs some CPU and pause time.
C++ frees memory deterministically through destructors, RAII and smart pointers, which is fast but risks leaks and dangling pointers if misused.
Q05Are arguments passed by value or by reference in these languages?SemanticsIntermediate
Java always passes by value, but for objects the value is a reference, so changes to the object are visible to the caller and reassignment is not. Python and JavaScript behave the same way.
C++ can pass by value, by reference (&) or by pointer. Go passes by value, but slices and maps contain pointers, so changes to their contents are visible.
Q06How do exceptions differ from returning errors?ErrorsIntermediate
Java, C++, Python and JavaScript throw exceptions that unwind the call stack until something catches them.
Go returns errors as ordinary values that the caller checks with if err != nil, and keeps panic for unrecoverable failures. Explicit errors are more visible; exceptions keep the main path shorter.
Q07How does Go support object-oriented design without classes?OOPIntermediate
Go uses structs with methods. Instead of inheritance it uses composition, embedding one struct in another.
Interfaces are satisfied implicitly: any type with the right methods implements the interface without declaring it.
Q08How do OS threads, goroutines and async/await differ?ConcurrencyAdvanced
OS threads are heavyweight, each with its own large stack, and are scheduled by the operating system. Goroutines are lightweight, managed by the Go runtime, multiplexed onto a few threads and usually communicate through channels. Java 21's virtual threads work in a similar way.
async/await in JavaScript and Python's asyncio runs on a single-threaded event loop, which suits I/O-heavy work but does not speed up CPU-heavy work.
Q09What is Python's GIL, and when does it matter?PythonAdvanced
CPython's Global Interpreter Lock lets only one thread run Python bytecode at a time, so CPU-heavy threads don't run in parallel.
I/O-bound threads are fine because the lock is released while waiting. For CPU-heavy work, use multiprocessing or libraries such as NumPy that release the lock. Python 3.13 also offers an optional build without the GIL.
These topics are taught in full in Five-Language Programming Bootcamp, a live cohort starting soon (date to be announced) · ₹24,000.