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 1251–1275 of 4608

Career & HR topics

By tech stack

Popular tracks

Mid PDF
Can interfaces have default implementations (C# 8+)?

Short answer: Yes, methods can have default implementations in interfaces. interface ILogger Example code { void Log(string message); void LogWarning(string message) => Console.WriteLine("Warning: " + messag…

Junior PDF
What is the difference between an interface and a class?

Short answer: Feature Interface Class Implementatio No implementation (except default methods) Can have full implementation Fields Cannot have fields Can have fields Instantiation Cannot instantiate Can instantiate Inher…

Mid PDF
Can a class implement multiple interfaces?

Short answer: Yes, a class can implement multiple interfaces, solving multiple inheritance issues. class FlyingCar : IDriveable, IFlyable Example code { public void Drive() => Console.WriteLine("Driving"); p…

Mid PDF
What happens if two interfaces have the same method signature?

Short answer: The implementing class must provide a single implementation for both interfaces. Or use explicit interface implementation to differentiate. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charg…

Mid PDF
Can you implement an interface explicitly?

Short answer: Yes, explicit implementation allows a class to implement interface members separately. class Car : IDriveable Example code { void IDriveable.Drive() => Console.WriteLine("Explicit drive"); } Re…

Junior PDF
What is explicit interface implementation?

Short answer: Implementing an interface member explicitly so it can only be called via interface reference, not class object. IDriveable car = new Car(); car.Drive(); // Works // Car c = new Car(); c.Drive(); // Won't co…

Junior PDF
What is the purpose of using interfaces?

Short answer: Define contracts for classes. Achieve abstraction, polymorphism, and loose coupling. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters implement the same i…

Mid PDF
How do interfaces help achieve abstraction?

Short answer: Expose method signatures without implementation. Users interact with the interface, not the underlying implementation. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and St…

Mid PDF
How do interfaces support loose coupling?

Short answer: Code depends on interface, not concrete class. Makes it easier to swap implementations without changing dependent code. void StartVehicle(IDriveable vehicle) { vehicle.Drive(); } Real-world example (ShopNes…

Mid PDF
How are interfaces used in dependency injection?

Short answer: Interfaces allow DI frameworks to inject concrete implementations at runtime. Promotes flexibility and testability. public class CarService { private readonly IDriveable _vehicle; public CarService(IDriveab…

Junior PDF
What is the IComparable interface?

Short answer: Provides a standard method to compare objects for sorting. class Employee : IComparable<Employee> Example code { public int Id { get; set; } public int CompareTo(Employee other) => this.Id.CompareT…

Junior PDF
What is the IDisposable interface?

Short answer: Provides Dispose() method for releasing unmanaged resources. class FileHandler : IDisposable Example code { public void Dispose() => Console.WriteLine("Resources released"); } Real-world exampl…

Junior PDF
What is the difference between IEnumerable and IEnumerator?

Short answer: IEnumerable → Provides collection traversal capability (GetEnumerator() method). IEnumerator → Used to iterate over a collection (MoveNext(), Current, Reset()). Real-world example (ShopNest) Think of ShopNe…

Mid PDF
Can one interface inherit another interface?

Short answer: Yes, interfaces can inherit from other interfaces, forming a hierarchy. interface IFlyable { void Fly(); } interface IAdvancedFlyable : IFlyable { void Loop(); } Example code Yes, interfaces can inherit fro…

Mid PDF
What are marker interfaces?

Short answer: Interfaces with no methods or properties, used to mark classes for special behavior. Example: ISerializable marks classes as serializable. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge…

Junior PDF
What is an abstract class?

Short answer: An abstract class is a class that cannot be instantiated directly. Can contain abstract methods (without implementation) and concrete methods (with implementation). Used to define a common base for other cl…

Mid PDF
How do you declare an abstract class in C#?

Short answer: Use the abstract keyword. abstract class Vehicle { Example code public abstract void Start(); public void Stop() => Console.WriteLine("Vehicle stopped"); } Real-world example (ShopNest) Checkou…

Junior PDF
What is an abstract method?

Short answer: A method declared with abstract without implementation. Must be overridden in a derived class. abstract class Vehicle { Example code public abstract void Start(); } class Car : Vehicle { public override voi…

Mid PDF
Can abstract classes have fields?

Short answer: Yes, abstract classes can have fields, properties, and constants. abstract class Vehicle { protected string Brand; } Example code Yes, abstract classes can have fields, properties, and constants. abstract c…

Mid PDF
Can abstract classes implement interfaces?

Short answer: Yes, abstract classes can implement interfaces partially or fully. Derived classes must implement any remaining abstract members. interface IDriveable { void Drive(); } abstract class Vehicle : IDriveable {…

Mid PDF
Can abstract classes be sealed?

Short answer: No, abstract classes cannot be sealed. A sealed class cannot be inherited, while abstract classes are meant to be inherited. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay…

Mid PDF
Can an abstract class have private members?

Short answer: Yes, abstract classes can have private members, but derived classes cannot access them. Private members can be accessed via protected or public methods. Real-world example (ShopNest) ShopNest’s Order keeps…

Mid PDF
Can a class be both abstract and static?

Short answer: No, a class cannot be both abstract and static. Abstract classes are for inheritance, static classes cannot be inherited. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and…

Junior PDF
What is the difference between an abstract method and a virtual method?

Short answer: llow derived class to optionally override Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . UpiPayment and CardPayment override the fee logic without changing the…

Junior PDF
What is the difference between an abstract method and a virtual method?

Short answer: Feature Abstract Method Virtual Method Implementatio No implementation Has implementation Must override? Must be overridden Optional to override Class type Must be in abstract class Can be in any class Purp…

C# OOP C# Programming Tutorial · OOP

Short answer: Yes, methods can have default implementations in interfaces. 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: Feature Interface Class Implementatio No implementation (except default methods) Can have full implementation Fields Cannot have fields Can have fields Instantiation Cannot instantiate Can instantiate Inheritance Can inherit multiple interfaces Single class inheritance only

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, a class can implement multiple interfaces, solving multiple inheritance issues. class FlyingCar : IDriveable, IFlyable

Example code

{
public void Drive() => Console.WriteLine("Driving");
public void Fly() => Console.WriteLine("Flying");
}

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: The implementing class must provide a single implementation for both interfaces. Or use explicit interface implementation to differentiate.

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, explicit implementation allows a class to implement interface members separately. class Car : IDriveable

Example code

{
void IDriveable.Drive() => Console.WriteLine("Explicit drive");
}

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 an interface member explicitly so it can only be called via interface reference, not class object. IDriveable car = new Car(); car.Drive(); // Works // Car c = new Car(); c.Drive(); // Won't compile

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 contracts for classes. Achieve abstraction, polymorphism, and loose 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: Expose method signatures without implementation. Users interact with the interface, not the underlying implementation.

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: Code depends on interface, not concrete class. Makes it easier to swap implementations without changing dependent code. void StartVehicle(IDriveable vehicle) { vehicle.Drive(); }

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 allow DI frameworks to inject concrete implementations at runtime. Promotes flexibility and testability. public class CarService { private readonly IDriveable _vehicle; public CarService(IDriveable vehicle) { _vehicle = vehicle; } }

Example code

Interfaces allow DI frameworks to inject concrete implementations at runtime. Promotes flexibility and testability. public class CarService
{
private readonly IDriveable _vehicle;
public CarService(IDriveable vehicle) { _vehicle = vehicle; }
}

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: Provides a standard method to compare objects for sorting. class Employee : IComparable<Employee>

Example code

{
public int Id { get; set; }
public int CompareTo(Employee other) => this.Id.CompareTo(other.Id); }

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: Provides Dispose() method for releasing unmanaged resources. class FileHandler : IDisposable

Example code

{
public void Dispose() => Console.WriteLine("Resources released"); }

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: IEnumerable → Provides collection traversal capability (GetEnumerator() method). IEnumerator → Used to iterate over a collection (MoveNext(), Current, Reset()).

Real-world example (ShopNest)

Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.

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, interfaces can inherit from other interfaces, forming a hierarchy. interface IFlyable { void Fly(); } interface IAdvancedFlyable : IFlyable { void Loop(); }

Example code

Yes, interfaces can inherit from other interfaces, forming a hierarchy. interface IFlyable { void Fly(); }
interface IAdvancedFlyable : IFlyable { void Loop(); }

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: Interfaces with no methods or properties, used to mark classes for special behavior. Example: ISerializable marks classes as serializable.

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: An abstract class is a class that cannot be instantiated directly. Can contain abstract methods (without implementation) and concrete methods (with implementation). Used to define a common base for other 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: Use the abstract keyword. abstract class Vehicle {

Example code

public abstract void Start();
public void Stop() => Console.WriteLine("Vehicle stopped");
}

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: A method declared with abstract without implementation. Must be overridden in a derived class. abstract class Vehicle {

Example code

public abstract void Start();
}
class Car : Vehicle
{
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: Yes, abstract classes can have fields, properties, and constants. abstract class Vehicle { protected string Brand; }

Example code

Yes, abstract classes can have fields, properties, and constants. abstract class Vehicle { protected string Brand; }

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 implement interfaces partially or fully. Derived classes must implement any remaining abstract members. interface IDriveable { void Drive(); } abstract class Vehicle : IDriveable { public abstract void Drive(); }

Example code

class Car : Vehicle { public override void Drive() => Console.WriteLine("Car drives"); }

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, abstract classes cannot be sealed. A sealed class cannot be inherited, while abstract classes are meant to be inherited.

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 private members, but derived classes cannot access them. Private members can be accessed via protected or public methods.

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

C# OOP C# Programming Tutorial · OOP

Short answer: No, a class cannot be both abstract and static. Abstract classes are for inheritance, static classes cannot be inherited.

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: llow derived class to optionally override

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: Feature Abstract Method Virtual Method Implementatio No implementation Has implementation Must override? Must be overridden Optional to override Class type Must be in abstract class Can be in any class Purpose Force derived classes to implement Allow derived class to optionally override

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
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