Interview Q&A

Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.

4608 total questions 4508 technical 100 career & HR 4272 from PDF library

Showing 51–75 of 372

Popular tracks

Mid PDF
Subject (NewsPublisher):?

Short answer: The NewsPublisher class acts as the subject in the Observer Pattern. It maintains a list of IObserver instances (subscribers) and provides methods to add (Subscribe), remove (Unsubscribe), and notify them (…

GoF Patterns Read answer
Mid PDF
Subject Interface (INewsPublisher):?

Short answer: This interface defines methods for subscribing, unsubscribing, and notifying observers. The subject manages a list of observers and notifies them when there is an update. public interface INewsPublisher Exa…

GoF Patterns Read answer
Mid PDF
Text Editor (Undo/Redo Functionality):?

Short answer: In a text editor (such as Microsoft Word or Notepad), users can press Ctrl + Z to undo the most recent changes. Each time the user types, the editor saves a snapshot of the text as a Memento. Pressing Ctrl…

GoF Patterns Read answer
Mid PDF
Memory Consumption:?

Short answer: If the object’s state is large or changes frequently, the Memento Pattern can result in significant memory usage, as you need to store many copies of the state (each memento). Real-world example (ShopNest)…

GoF Patterns Read answer
Mid PDF
Encapsulation Preservation:?

Short answer: The Memento Pattern preserves encapsulation because the state is stored in the Memento object, and the TextEditor is not exposed to direct manipulation of its internal state. The only way to change or acces…

GoF Patterns Read answer
Mid PDF
TextEditor (Originator):?

Short answer: The TextEditor is the originator of the state. It holds the text that changes over time and can save and restore its state using mementos. Real-world example (ShopNest) Use a GoF pattern in ShopNest only wh…

GoF Patterns Read answer
Mid PDF
Chat Application:?

Short answer: A classic example of the Mediator Pattern is a chat application, where the mediator is responsible for sending messages between users. It ensures that messages are routed correctly without the users needing…

GoF Patterns Read answer
Mid PDF
Loose Coupling:?

Short answer: The Mediator Pattern decouples objects from each other by centralizing communication through the mediator. Users don't need to know about each other and only communicate via the mediator. This reduces depen…

GoF Patterns Read answer
Mid PDF
Mediator (ChatMediator):?

Short answer: The mediator manages communication between the users. It maintains a list of all users and broadcasts messages to all other users when one user sends a message. This keeps the users from directly knowing ab…

GoF Patterns Read answer
Mid PDF
Mediator Interface (IChatMediator):?

Short answer: The IChatMediator interface defines two key operations: ■ SendMessage(string message, User user): Sends a message from a user to all other registered users. ■ RegisterUser(User user): Registers users with t…

GoF Patterns Read answer
Mid PDF
Reverse Iteration:?

Short answer: The Iterator Pattern can be extended to support reverse iteration or provide additional functionality like removing items during iteration. Real-world example (ShopNest) Use a GoF pattern in ShopNest only w…

GoF Patterns Read answer
Mid PDF
Iterating Over a List of Products:?

Short answer: The Iterator Pattern is commonly used when working with product lists, customer lists, or any other collection where you need to iterate over items sequentially. For instance, in an e-commerce application,…

GoF Patterns Read answer
Mid PDF
Iterator Interface (IIterator<T>):?

Short answer: The IIterator&lt;T&gt; interface defines two primary methods: ■ HasNext(): Checks if there are more elements to iterate over. ■ Next(): Returns the next element in the collection. public interface IIterator…

GoF Patterns Read answer
Mid PDF
Optimization:?

Short answer: For more complex grammars, the interpreter may become inefficient. Optimizations such as memoization (caching results) can be used to avoid redundant evaluations, particularly for recursive expressions. Rea…

GoF Patterns Read answer
Mid PDF
Mathematical Expression Evaluation:?

Short answer: Calculator applications that need to parse and evaluate mathematical expressions like 5 + 3 * 2 can leverage the Interpreter Pattern to handle different operators and operands. Each part of the expression (…

GoF Patterns Read answer
Mid PDF
Flexible Grammar Definition:?

Short answer: The Interpreter Pattern is ideal for scenarios where the grammar is complex and subject to change. By defining expressions as objects, it’s easy to extend or modify the grammar without affecting other parts…

GoF Patterns Read answer
Mid PDF
Abstract Expression (IExpression):?

Short answer: The IExpression interface declares an Interpret method, which is the core of the interpreter pattern. This method is used to interpret and evaluate expressions. public interface IExpression Example code { i…

GoF Patterns Read answer
Mid PDF
Cache Management:?

Short answer: If the number of unique characters or objects grows significantly, the CharacterFactory can implement cache management strategies like LRU (Least Recently Used) or FIFO (First In, First Out) to evict older…

GoF Patterns Read answer
Mid PDF
Text Rendering in Games:?

Short answer: Many games display large amounts of text (e.g., in dialogues, menus, or scores). Using the Flyweight Pattern, you can optimize memory usage by reusing the same Character objects for common letters or symbol…

GoF Patterns Read answer
Mid PDF
Flyweight Objects (Character):?

Short answer: The Character class holds the intrinsic state (the character symbol), which is shared across all instances. This makes it an ideal candidate for the Flyweight Pattern because multiple characters (e.g., 'H',…

GoF Patterns Read answer
Mid PDF
Flyweight (Character):?

Short answer: This class represents the Flyweight object. It contains the intrinsic state that is shared across multiple instances (the character symbol, in this case), and it provides a Display method to show the charac…

GoF Patterns Read answer
Mid PDF
Dynamic Factory Selection:?

Short answer: In a more advanced system, you could dynamically choose which factory to use based on external configurations, like settings or environment variables. This would enable the system to switch between differen…

GoF Patterns Read answer
Mid PDF
Logging Frameworks:?

Short answer: As mentioned, logging systems often use the Factory Method to allow different log outputs. For example, a logging framework can provide loggers that write to the console, files, databases, or cloud services…

GoF Patterns Read answer
Mid PDF
Abstract Factory (LoggerFactory):?

Short answer: The LoggerFactory class defines a factory method CreateLogger that returns an ILogger object. This is a generic interface for creating various logger types without specifying the concrete class directly. Re…

GoF Patterns Read answer
Mid PDF
Product Interface (ILogger):?

Short answer: This interface defines the common method Log that will be implemented by all types of loggers (e.g., file, console). public interface ILogger Example code { void Log(string message); } Say this in the inter…

GoF Patterns Read answer

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The NewsPublisher class acts as the subject in the Observer Pattern. It maintains a list of IObserver instances (subscribers) and provides methods to add (Subscribe), remove (Unsubscribe), and notify them (Notify).

Real-world example (ShopNest)

When order status changes, observers update email, SMS, and analytics without the Order class knowing each one.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: This interface defines methods for subscribing, unsubscribing, and notifying observers. The subject manages a list of observers and notifies them when there is an update. public interface INewsPublisher

Example code

{ void Subscribe(IObserver observer); void Unsubscribe(IObserver observer); void Notify(string news); }

Real-world example (ShopNest)

When order status changes, observers update email, SMS, and analytics without the Order class knowing each one.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: In a text editor (such as Microsoft Word or Notepad), users can press Ctrl + Z to undo the most recent changes. Each time the user types, the editor saves a snapshot of the text as a Memento. Pressing Ctrl + Z restores the text to its previous state.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: If the object’s state is large or changes frequently, the Memento Pattern can result in significant memory usage, as you need to store many copies of the state (each memento).

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Memento Pattern preserves encapsulation because the state is stored in the Memento object, and the TextEditor is not exposed to direct manipulation of its internal state. The only way to change or access the state is through well-defined methods (Save and Restore).

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The TextEditor is the originator of the state. It holds the text that changes over time and can save and restore its state using mementos.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: A classic example of the Mediator Pattern is a chat application, where the mediator is responsible for sending messages between users. It ensures that messages are routed correctly without the users needing to know about each other.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Mediator Pattern decouples objects from each other by centralizing communication through the mediator. Users don't need to know about each other and only communicate via the mediator. This reduces dependencies and makes the system easier to maintain.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The mediator manages communication between the users. It maintains a list of all users and broadcasts messages to all other users when one user sends a message. This keeps the users from directly knowing about each other, thus promoting loose coupling.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The IChatMediator interface defines two key operations: ■ SendMessage(string message, User user): Sends a message from a user to all other registered users. ■ RegisterUser(User user): Registers users with the mediator so they can send and receive messages. public interface IChatMediator

Example code

{ void SendMessage(string message, User user); void RegisterUser(User user); }

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Iterator Pattern can be extended to support reverse iteration or provide additional functionality like removing items during iteration.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Iterator Pattern is commonly used when working with product lists, customer lists, or any other collection where you need to iterate over items sequentially. For instance, in an e-commerce application, you might use an iterator to list products, iterate through available categories, or paginate results.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The IIterator<T> interface defines two primary methods: ■ HasNext(): Checks if there are more elements to iterate over. ■ Next(): Returns the next element in the collection. public interface IIterator<T>

Example code

{ bool HasNext(); T Next(); }

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: For more complex grammars, the interpreter may become inefficient. Optimizations such as memoization (caching results) can be used to avoid redundant evaluations, particularly for recursive expressions.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: Calculator applications that need to parse and evaluate mathematical expressions like 5 + 3 * 2 can leverage the Interpreter Pattern to handle different operators and operands. Each part of the expression (numbers, operators) is represented as an object that can be evaluated.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Interpreter Pattern is ideal for scenarios where the grammar is complex and subject to change. By defining expressions as objects, it’s easy to extend or modify the grammar without affecting other parts of the system.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The IExpression interface declares an Interpret method, which is the core of the interpreter pattern. This method is used to interpret and evaluate expressions. public interface IExpression

Example code

{
int Interpret();
}

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: If the number of unique characters or objects grows significantly, the CharacterFactory can implement cache management strategies like LRU (Least Recently Used) or FIFO (First In, First Out) to evict older or unused objects and maintain memory efficiency.

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: Many games display large amounts of text (e.g., in dialogues, menus, or scores). Using the Flyweight Pattern, you can optimize memory usage by reusing the same Character objects for common letters or symbols, rather than creating a new object for each instance.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The Character class holds the intrinsic state (the character symbol), which is shared across all instances. This makes it an ideal candidate for the Flyweight Pattern because multiple characters (e.g., 'H', 'e', 'l') may appear many times in the same text, but they only need one Character object for the symbol.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: This class represents the Flyweight object. It contains the intrinsic state that is shared across multiple instances (the character symbol, in this case), and it provides a Display method to show the character's symbol at a particular coordinate. public class Character

Example code

{
private readonly char _symbol;
public Character(char symbol) => _symbol = symbol;
public void Display(int x, int y) => Console.WriteLine($"Character: {_symbol} at ({x}, {y})"); }

Real-world example (ShopNest)

Use a GoF pattern in ShopNest only when it removes duplication or makes a change safer—explain the problem it solves in the interview.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: In a more advanced system, you could dynamically choose which factory to use based on external configurations, like settings or environment variables. This would enable the system to switch between different logging mechanisms or database connections without recompiling the application.

Real-world example (ShopNest)

ShopNest’s NotificationFactory creates Email or SMS senders based on user preference.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: As mentioned, logging systems often use the Factory Method to allow different log outputs. For example, a logging framework can provide loggers that write to the console, files, databases, or cloud services, with the user choosing the appropriate logger type via a factory.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: The LoggerFactory class defines a factory method CreateLogger that returns an ILogger object. This is a generic interface for creating various logger types without specifying the concrete class directly.

Real-world example (ShopNest)

ShopNest’s NotificationFactory creates Email or SMS senders based on user preference.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

Gang of Four Patterns Design Patterns in C# · GoF Patterns

Short answer: This interface defines the common method Log that will be implemented by all types of loggers (e.g., file, console). public interface ILogger

Example code

{ void Log(string message); }

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details