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 276–300 of 398

Career & HR topics

By tech stack

Mid PDF
When should you prefer abstract class over an interface?

Short answer: When you want to share common code among related classes. When you need fields or constructors. When future changes may require adding non-breaking methods. Real-world example (ShopNest) Checkout calls IPay…

Mid PDF
Can you implement multiple interfaces?

Short answer: Can you inherit multiple abstract classes? Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance) Real-world example (ShopNest) Checkout calls IPaymentGate…

Mid PDF
Can you implement multiple interfaces? Can you inherit multiple

Short answer: bstract classes? Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance) Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decima…

Mid PDF
Can you implement multiple interfaces?

Short answer: Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance) Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters…

Mid PDF
Which allows multiple inheritance — interface or abstract class?

Short answer: Interface allows multiple inheritance. Interface allows multiple inheritance. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . UpiPayment and CardPayment override…

Mid PDF
Can interfaces contain implementation (default interface methods)?

Short answer: Yes, starting from C# 8, interfaces can have default method implementations. interface ILogger Example code { void Log(string message); void LogWarning(string message) => Console.WriteLine("Warning:…

Mid PDF
Can abstract classes provide full implementation?

Short answer: Yes, abstract classes can have fully implemented methods along with abstract methods. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters implement the same…

Mid PDF
Can you have properties in both interfaces and abstract classes?

Short answer: Yes, both can define properties. Interface properties are abstract by default; abstract class properties can have implementation. interface ICar { int Speed { get; set; } } abstract class Vehicle { public i…

Mid PDF
Can you create an object of an interface?

Short answer: No, you cannot instantiate an interface. You can only use it as a reference type. ICar car = new Car(); // Interface reference // ICar c = new ICar(); // Not allowed Example code No, you cannot instantiate…

Mid PDF
Can you use abstract classes with dependency injection?

Short answer: Yes, abstract classes can be injected as service contracts, but interfaces are preferred for looser coupling. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adap…

Mid PDF
What are the similarities between interfaces and abstract classes?

Short answer: Both can define contracts for derived classes. Both support polymorphism. Both cannot be instantiated directly. Both can be used with dependency injection. Real-world example (ShopNest) Checkout calls IPaym…

Mid PDF
How are interface contracts different from abstract class contracts?

Short answer: Interface contracts are pure method signatures. Abstract class contracts can contain shared code and fields. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapt…

Mid PDF
What happens if both interface and abstract class have the same method signature?

Short answer: Implementing class must provide implementation once. Explicit interface implementation can resolve ambiguity. interface IDriveable { void Start(); } abstract class Vehicle { public abstract void Start(); }…

Mid PDF
Can an interface inherit from an abstract class?

Short answer: No, interfaces can only inherit other interfaces. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . UpiPayment and CardPayment override the fee logic without chang…

Mid PDF
Can an abstract class implement an interface?

Short answer: Yes, abstract classes can implement interfaces partially or fully. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters implement the same interface, so ShopN…

Mid PDF
What are the performance differences between interfaces and

Short answer: bstract classes? Abstract classes are slightly faster because they use direct method calls. Interfaces may incur slight overhead due to indirect method calls via vtable. Difference is usually negligible in…

Mid PDF
What are the performance differences between interfaces and abstract classes?

Short answer: Abstract classes are slightly faster because they use direct method calls. Interfaces may incur slight overhead due to indirect method calls via vtable. Difference is usually negligible in most applications…

Mid PDF
Which is better for API design: interface or abstract class?

Short answer: Interfaces are preferred for public APIs because they: Allow multiple inheritance Support loose coupling Avoid breaking changes when adding new implementations Abstract classes are better for internal APIs…

Mid PDF
How does versioning work differently for interfaces and abstract classes?

Short answer: Interfaces: Adding new members breaks existing implementations unless using default interface methods (C# 8+). Abstract Classes: Can add new methods with implementation without breaking derived classes. Exa…

Mid PDF
Which supports multiple inheritance in C#?

Short answer: Interfaces support multiple inheritance. Abstract classes do not. Interview Q&A Example code Interfaces support multiple inheritance. Abstract classes do not. Interview Q&A Real-world example (ShopN…

Mid PDF
How would you design a plugin system using interfaces?

Short answer: Define an interface like IPlugin with a Run() method. Explain a bit more Each plugin implements IPlugin and can be loaded dynamically. interface IPlugin { void Run(); } class PluginA : IPlugin { public void…

Mid PDF
How would you design a payment system using abstract classes

Short answer: And interfaces? Use an interface for common operations: IPayment. Use an abstract class for shared behavior like logging. interface IPayment { void Pay(decimal amount); } bstract class PaymentBase : IPaymen…

Mid PDF
How would you design a payment system using abstract classes and interfaces?

Short answer: Use an interface for common operations: IPayment. Use an abstract class for shared behavior like logging. interface IPayment { void Pay(decimal amount); } abstract class PaymentBase : IPayment { Example cod…

Mid PDF
How can you implement a notification system using polymorphism?

Short answer: Define a base Notification class or interface. Derive classes like EmailNotification, SMSNotification. abstract class Notification { public abstract void Send(string message); } class EmailNotification : No…

Mid PDF
What’s the role of encapsulation in API security?

Short answer: Protects internal data by restricting direct access. Ensures sensitive fields are accessed only via methods/properties, preventing misuse. Real-world example (ShopNest) ShopNest’s Order keeps _items private…

C# OOP C# Programming Tutorial · OOP

Short answer: When you want to share common code among related classes. When you need fields or constructors. When future changes may require adding non-breaking methods.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Can you inherit multiple abstract classes? Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance)

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: bstract classes? Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance)

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance)

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Interface allows multiple inheritance. Interface allows multiple inheritance.

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Yes, starting from C# 8, interfaces can have default method implementations. interface ILogger

Example code

{ void Log(string message); void LogWarning(string message) => Console.WriteLine("Warning: " + message); }

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Yes, abstract classes can have fully implemented methods along with abstract methods.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Yes, both can define properties. Interface properties are abstract by default; abstract class properties can have implementation. interface ICar { int Speed { get; set; } } abstract class Vehicle { public int Speed { get; set; } }

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: No, you cannot instantiate an interface. You can only use it as a reference type. ICar car = new Car(); // Interface reference // ICar c = new ICar(); // Not allowed

Example code

No, you cannot instantiate an interface. You can only use it as a reference type. ICar car = new Car(); // Interface reference
// ICar c = new ICar(); // Not allowed

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Yes, abstract classes can be injected as service contracts, but interfaces are preferred for looser coupling.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Both can define contracts for derived classes. Both support polymorphism. Both cannot be instantiated directly. Both can be used with dependency injection.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Interface contracts are pure method signatures. Abstract class contracts can contain shared code and fields.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Implementing class must provide implementation once. Explicit interface implementation can resolve ambiguity. interface IDriveable { void Start(); } abstract class Vehicle { public abstract void Start(); } class Car : Vehicle, IDriveable

Example code

{
public override void Start() => Console.WriteLine("Car started"); }

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: No, interfaces can only inherit other interfaces.

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Yes, abstract classes can implement interfaces partially or fully.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: bstract classes? Abstract classes are slightly faster because they use direct method calls. Interfaces may incur slight overhead due to indirect method calls via vtable. Difference is usually negligible in most applications.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Abstract classes are slightly faster because they use direct method calls. Interfaces may incur slight overhead due to indirect method calls via vtable. Difference is usually negligible in most applications.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Interfaces are preferred for public APIs because they: Allow multiple inheritance Support loose coupling Avoid breaking changes when adding new implementations Abstract classes are better for internal APIs where shared code is required.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Interfaces: Adding new members breaks existing implementations unless using default interface methods (C# 8+). Abstract Classes: Can add new methods with implementation without breaking derived classes.

Example code

Interfaces: Adding new members breaks existing implementations unless using default interface methods (C# 8+). Abstract Classes: Can add new methods with implementation without breaking derived classes.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Interfaces support multiple inheritance. Abstract classes do not. Interview Q&A

Example code

Interfaces support multiple inheritance. Abstract classes do not. Interview Q&A

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Define an interface like IPlugin with a Run() method.

Explain a bit more

Each plugin implements IPlugin and can be loaded dynamically. interface IPlugin { void Run(); } class PluginA : IPlugin { public void Run() => Console.WriteLine("Plugin A running"); } class PluginB : IPlugin { public void Run() => Console.WriteLine("Plugin B running"); } // Usage List<IPlugin> plugins = new List<IPlugin> { new PluginA(), new PluginB() }; foreach (var p in plugins) p.Run();

Example code

Define an interface like IPlugin with a Run() method. Each plugin implements IPlugin and can be loaded dynamically. interface IPlugin { void Run(); }
class PluginA : IPlugin { public void Run() => Console.WriteLine("Plugin A running"); } class PluginB : IPlugin { public void Run() => Console.WriteLine("Plugin B running"); } // Usage List<IPlugin> plugins = new List<IPlugin> { new PluginA(), new PluginB() }; foreach (var p in plugins) p.Run();

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: And interfaces? Use an interface for common operations: IPayment. Use an abstract class for shared behavior like logging. interface IPayment { void Pay(decimal amount); } bstract class PaymentBase : IPayment { public abstract void Pay(decimal amount); public void Log(string message) => Console.WriteLine(message); } class CreditCardPayment :… PaymentBase {……… nd interfaces? nd interfaces? Use an interface for common…

Explain a bit more

operations: IPayment. Use an abstract class for shared behavior like logging. interface IPayment { void Pay(decimal amount); } bstract class PaymentBase : IPayment { public abstract void Pay(decimal amount); public void Log(string message) => Console.WriteLine(message); } class CreditCardPayment : PaymentBase {… nd interfaces? Use an interface for common operations: IPayment. Use an abstract class for shared behavior like logging. interface IPayment { void Pay(decimal amount); } bstract class PaymentBase : IPayment { public abstract void Pay(decimal amount); public void Log(string message) => Console.WriteLine(message); } class… And… public abstract void Pay(decimal amount);

Example code

public void Log(string message) => Console.WriteLine(message);
}
class CreditCardPayment : PaymentBase
{
public override void Pay(decimal amount) => Console.WriteLine($"Paid {amount} by Credit Card"); }

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Use an interface for common operations: IPayment. Use an abstract class for shared behavior like logging. interface IPayment { void Pay(decimal amount); } abstract class PaymentBase : IPayment {

Example code

public abstract void Pay(decimal amount);
public void Log(string message) => Console.WriteLine(message);
}
class CreditCardPayment : PaymentBase
{
public override void Pay(decimal amount) => Console.WriteLine($"Paid {amount} by Credit Card"); }

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Define a base Notification class or interface. Derive classes like EmailNotification, SMSNotification. abstract class Notification { public abstract void Send(string message); } class EmailNotification : Notification { public override void

Example code

Send(string msg) => Console.WriteLine("Email: " + msg); }
class SMSNotification : Notification { public override void
Send(string msg) => Console.WriteLine("SMS: " + msg); }
List<Notification> notifications = new List<Notification> { new EmailNotification(), new SMSNotification() }; foreach (var n in notifications) n.Send("Hello World!");

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Protects internal data by restricting direct access. Ensures sensitive fields are accessed only via methods/properties, preventing misuse.

Real-world example (ShopNest)

ShopNest’s Order keeps _items private and exposes AddItem() so totals stay correct—callers cannot put a negative quantity directly into the list.

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