Skip to main content

Interview questions · Book 01

Programming Fundamentals interview questions

243 questions from 62 pages, each with a short answer. Say your answer first, then open the question to check it.

p. 1 · 4 questions

Abstract Class

Full page
  1. 1

    What is an abstract class?

    An abstract class is a class that can't be instantiated on its own; it shares code with its subclasses and declares methods that each subclass must implement.

  2. 2

    What is the difference between an abstract class and an interface?

    An interface only declares what a type can do, and a class can implement several. An abstract class can also hold fields, a constructor and shared method code, but a class can extend only one. Use an interface for a capability and an abstract class for behavior shared by a family of related types.

  3. 3

    Can an abstract class have a constructor?

    Yes. You can't call it with new directly, but each subclass calls it, for example with super(...), to set up the fields that the abstract class defines.

  4. 4

    Does Python have abstract classes?

    Not as a keyword, but the standard abc module provides them. Inherit from ABC and mark methods with @abstractmethod, and Python raises a TypeError if you try to create an object before every abstract method is implemented.

p. 2 · 4 questions

Abstraction

Full page
  1. 1

    What is abstraction in programming?

    Abstraction is hiding the complicated details of how something works behind a simpler interface, so code can use it by knowing only what it does.

  2. 2

    What is the difference between abstraction and encapsulation?

    Abstraction decides what to show: a simple interface that captures the essential idea. Encapsulation is how the rest is kept hidden: private fields and methods that outside code can't touch.

  3. 3

    What is an abstract class?

    A class that can't be instantiated directly and may leave some methods unimplemented. Subclasses fill in the details. Unlike an interface, it can also contain shared code and fields.

  4. 4

    What is a leaky abstraction?

    An abstraction whose hidden details still affect the people using it. For example, an ORM hides SQL, but slow queries still force developers to understand the SQL it generates.

p. 3 · 4 questions

Algorithm

Full page
  1. 1

    What is an algorithm?

    An algorithm is a finite, step-by-step set of instructions for solving a problem or completing a task, such as sorting a list or finding the shortest route.

  2. 2

    What is the difference between an algorithm and a program?

    An algorithm is the abstract sequence of steps for solving a problem. A program is a concrete implementation of that algorithm, usually along with many others, written in a specific programming language so a computer can run it.

  3. 3

    What is Big O notation?

    Big O notation describes how an algorithm's running time or memory use grows as the input size grows. For example, O(n) means the work grows in direct proportion to the input, while O(1) means it stays the same no matter how large the input is.

  4. 4

    Do I need to know algorithms to be a developer?

    You don't need to memorize every algorithm, but understanding common ones like searching and sorting, and knowing how to reason about efficiency, helps you write faster code. Algorithm questions are also common in technical interviews.

p. 4 · 4 questions

Array

Full page
  1. 1

    What is an array?

    An array is an ordered collection of values stored under one name, where each item is accessed by its numeric position, called an index, usually starting at 0.

  2. 2

    Why do arrays start at index 0?

    In languages like C, an index is the distance, or offset, from the start of the array in memory, so the first item is zero steps away. Most later languages kept this convention, although a few, such as Lua, MATLAB, and R, start counting at 1.

  3. 3

    What is the difference between an array and a list?

    The terms overlap. Classically, an array is a fixed-size block of contiguous memory, while a list can grow and shrink; Python's list and JavaScript's Array are actually dynamic arrays that combine fast index access with automatic resizing.

  4. 4

    How do I check if a value is an array in JavaScript?

    Use Array.isArray(value), which returns true only for arrays. The typeof operator doesn't help here, because it returns "object" for arrays as well as for plain objects.

p. 5 · 4 questions

Async/Await

Full page
  1. 1

    What is async/await?

    Async/await is a syntax for writing asynchronous code that reads like ordinary step-by-step code, pausing at each await until a promise or task finishes.

  2. 2

    Does await block the main thread?

    No. await pauses only the async function it is in; the rest of the program, including the browser's user interface, keeps running. The function resumes once the awaited promise settles.

  3. 3

    Can I use await outside an async function?

    In modern JavaScript, you can use top-level await directly in ES modules. In classic scripts and CommonJS files, await must be inside an async function.

  4. 4

    What is the difference between async/await and promises?

    Async/await is syntax built on top of promises, not a replacement for them. It lets you write the same promise-based logic in a more linear, readable style.

p. 6 · 3 questions

Base64

Full page
  1. 1

    What is Base64?

    Base64 is a way to write any binary data, such as an image or a key, using only 64 safe text characters, so it can pass through systems built for text.

  2. 2

    Is Base64 encryption?

    No. Base64 only changes how the bytes are written, and anyone can turn it back without a key. To keep data secret, encrypt it; Base64 is just a way to carry the result as text.

  3. 3

    Why does Base64 sometimes end with = or ==?

    Base64 works on groups of three bytes. When the last group has only one or two, the output is padded with == or = so its length is a multiple of four. Some formats, such as JWTs, leave the padding out.

p. 7 · 4 questions

Big O Notation

Full page
  1. 1

    What is Big O notation?

    Big O notation describes how an algorithm's running time or memory use grows as its input gets larger, focusing on the growth rate rather than exact speed.

  2. 2

    What does O(n) mean?

    O(n), or linear time, means the work grows in direct proportion to the input size. If an O(n) function takes 1 millisecond for 1,000 items, it will take roughly 10 milliseconds for 10,000 items.

  3. 3

    What is the difference between time complexity and space complexity?

    Time complexity describes how the number of steps an algorithm takes grows with the input, while space complexity describes how much extra memory it needs. Both are usually expressed in Big O notation, and improving one often costs the other.

  4. 4

    Is O(log n) faster than O(n)?

    Yes, for large inputs. O(log n) work grows very slowly, since doubling the input adds only about one extra step, so binary search can find an item among a billion sorted values in about 30 comparisons.

p. 8 · 4 questions

Callback

Full page
  1. 1

    What is a callback?

    A callback is a function passed as an argument to another function, which then calls it later, for example when a task finishes or an event happens.

  2. 2

    What is the difference between a callback and a promise?

    A callback is a function you pass in to be called when work finishes. A promise is an object that represents the future result of that work, which you can chain with .then() or wait for with await; promises make sequencing and error handling much simpler than nested callbacks.

  3. 3

    What is callback hell?

    Callback hell is code where many asynchronous callbacks are nested inside each other, forming a pyramid shape that is hard to read, debug, and handle errors in. It is usually fixed by switching to promises or async/await.

  4. 4

    Are callbacks always asynchronous?

    No. Callbacks passed to array methods like map, filter, and forEach run synchronously, immediately during the call. Only callbacks tied to timers, events, or input/output operations run asynchronously.

More

Settings