Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Code depends on interfaces or base classes, not concrete implementations. Makes system flexible, extendable, and easier to maintain. void StartVehicle(Vehicle v) { v.Start(); } // Works with any derived typ…
Short answer: Advantages: Promotes code reuse and flexibility Enables loose coupling Supports extensible architecture Disadvantages: May introduce runtime overhead Can make code harder to understand if overused Requires…
Short answer: An interface is a contract that defines method signatures, properties, events, or indexers without providing implementation. Classes or structs that implement the interface must provide the implementation.…
Short answer: Use the interface keyword. interface IDriveable Example code { void Drive(); int Speed { get; set; } } Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters im…
Short answer: Use the colon (:) symbol and implement all members. class Car : IDriveable Example code { public int Speed { get; set; } public void Drive() => Console.WriteLine("Car is driving"); } Real-world…
Short answer: No, interfaces cannot have fields. Only methods, properties, events, or indexers. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters implement the same inte…
Short answer: No, interfaces cannot have constructors. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways wi…
Short answer: Yes, starting from C# 8, interfaces can contain static methods. interface IUtility Example code { static void Show() => Console.WriteLine("Static method in interface"); } Real-world example (Sh…
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…
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…
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…
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…
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…
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…
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…
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…
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…
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…
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…
Short answer: Provides Dispose() method for releasing unmanaged resources. class FileHandler : IDisposable Example code { public void Dispose() => Console.WriteLine("Resources released"); } Real-world exampl…
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…
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…
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…
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…
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…
C# OOP C# Programming Tutorial · OOP
Short answer: Code depends on interfaces or base classes, not concrete implementations. Makes system flexible, extendable, and easier to maintain. void StartVehicle(Vehicle v) { v.Start(); } // Works with any derived type
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Advantages: Promotes code reuse and flexibility Enables loose coupling Supports extensible architecture Disadvantages: May introduce runtime overhead Can make code harder to understand if overused Requires careful design to avoid ambiguity
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: An interface is a contract that defines method signatures, properties, events, or indexers without providing implementation. Classes or structs that implement the interface must provide the implementation.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Use the interface keyword. interface IDriveable
{ void Drive(); int Speed { get; set; }
}
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Use the colon (:) symbol and implement all members. class Car : IDriveable
{
public int Speed { get; set; }
public void Drive() => Console.WriteLine("Car is driving");
}
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: No, interfaces cannot have fields. Only methods, properties, events, or indexers.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: No, interfaces cannot have constructors.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Yes, starting from C# 8, interfaces can contain static methods. interface IUtility
{ static void Show() => Console.WriteLine("Static method in interface");
}
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Yes, methods can have default implementations in interfaces. interface ILogger
{ void Log(string message); void LogWarning(string message) => Console.WriteLine("Warning: " + message); }
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
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
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Yes, a class can implement multiple interfaces, solving multiple inheritance issues. class FlyingCar : IDriveable, IFlyable
{
public void Drive() => Console.WriteLine("Driving");
public void Fly() => Console.WriteLine("Flying");
}
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
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.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Yes, explicit implementation allows a class to implement interface members separately. class Car : IDriveable
{
void IDriveable.Drive() => Console.WriteLine("Explicit drive");
}
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
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
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Define contracts for classes. Achieve abstraction, polymorphism, and loose coupling.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Expose method signatures without implementation. Users interact with the interface, not the underlying implementation.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
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(); }
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
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; } }
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; }
}
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Provides a standard method to compare objects for sorting. class Employee : IComparable<Employee>
{
public int Id { get; set; }
public int CompareTo(Employee other) => this.Id.CompareTo(other.Id); }
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Provides Dispose() method for releasing unmanaged resources. class FileHandler : IDisposable
{
public void Dispose() => Console.WriteLine("Resources released"); }
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
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()).
Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.
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(); }
Yes, interfaces can inherit from other interfaces, forming a hierarchy. interface IFlyable { void Fly(); }
interface IAdvancedFlyable : IFlyable { void Loop(); }
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.
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.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
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.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Use the abstract keyword. abstract class Vehicle {
public abstract void Start();
public void Stop() => Console.WriteLine("Vehicle stopped");
}
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
Install Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.