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: 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: 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: 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: 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: 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…
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…
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 {…
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…
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…
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…
Short answer: Abstract classes can provide shared implementation, fields, and constructors. Useful when multiple classes share common behavior along with enforced abstraction. Real-world example (ShopNest) Checkout calls…
Short answer: abstract class Employee { Example code public string Name { get; set; } public abstract void Work(); public void Report() => Console.WriteLine("Reporting work done"); } class Developer : Employ…
Short answer: No, abstract methods must be overridden with override in derived classes. You can then mark the overriding method as virtual to allow further overriding in subclasses. abstract class Vehicle { public abstra…
Short answer: No, C# does not allow multiple class inheritance. Use interfaces as a workaround. interface IFlyable { void Fly(); } interface IDriveable { void Drive(); } class FlyingCar : IFlyable, IDriveable { public vo…
Short answer: When you want to define pure contracts without implementation. When you need multiple inheritance. When you want loose coupling for dependency injection. Real-world example (ShopNest) Checkout calls IPaymen…
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: 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: 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: 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: 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: 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.
C# OOP C# Programming Tutorial · OOP
Short answer: Yes, abstract classes can have fields, properties, and constants. abstract class Vehicle { protected string Brand; }
Yes, abstract classes can have fields, properties, and constants. abstract class Vehicle { protected string Brand; }
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, 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(); }
class Car : Vehicle { public override void Drive() => Console.WriteLine("Car drives"); }
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, abstract classes cannot be sealed. A sealed class cannot be inherited, while abstract classes are meant to be inherited.
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, abstract classes can have private members, but derived classes cannot access them. Private members can be accessed via protected or public methods.
ShopNest’s Order keeps _items private and exposes AddItem() so totals stay correct—callers cannot put a negative quantity directly into the list.
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.
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: Abstract classes can provide shared implementation, fields, and constructors. Useful when multiple classes share common behavior along with enforced abstraction.
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: abstract class Employee {
public string Name { get; set; }
public abstract void Work();
public void Report() => Console.WriteLine("Reporting work done"); }
class Developer : Employee
{
public override void Work() => Console.WriteLine("Writing code"); }
class Tester : Employee
{
public override void Work() => Console.WriteLine("Testing application"); } // Usage Employee dev = new Developer() { Name = "Alice" }; dev.Work(); dev.Report();
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, abstract methods must be overridden with override in derived classes. You can then mark the overriding method as virtual to allow further overriding in subclasses. abstract class Vehicle { public abstract void Start(); } class Car : Vehicle { public override void Start() => Console.WriteLine("Car starts"); }
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: No, C# does not allow multiple class inheritance. Use interfaces as a workaround. interface IFlyable { void Fly(); } interface IDriveable { void Drive(); } class FlyingCar : IFlyable, IDriveable { public void Fly() {} public void Drive() {} } Q&A
No, C# does not allow multiple class inheritance. Use interfaces as a workaround. interface IFlyable { void Fly(); }
interface IDriveable { void Drive(); }
class FlyingCar : IFlyable, IDriveable { public void Fly() {} public void Drive() {} } Q&A
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: When you want to define pure contracts without implementation. When you need multiple inheritance. When you want loose coupling for dependency injection.
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.