Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
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: Feature Abstract Class Normal Class Instantiation Cannot instantiate Can instantiate Methods Can have abstract methods All methods must have implementation Purpose Serve as base for inheritance General purp…
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: Feature Abstract Class Interface Implementation Can have full/partial implementation Cannot have full implementation (except default methods in C# 8+) Fields Can have fields Cannot have fields Inheritance S…
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…
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…
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…
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…
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…
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…
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:…
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…
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…
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…
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…
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…
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…
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(); }…
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…
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…
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…
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…
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…
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: Feature Abstract Class Normal Class Instantiation Cannot instantiate Can instantiate Methods Can have abstract methods All methods must have implementation Purpose Serve as base for inheritance General purpose use
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: Feature Abstract Class Interface Implementation Can have full/partial implementation Cannot have full implementation (except default methods in C# 8+) Fields Can have fields Cannot have fields Inheritance Single class inheritance Multiple interface inheritance allowed Constructors Allowed Not allowed Access Modifiers Can have public, protected, private Members are public by default
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: 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.
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.
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: Can you inherit multiple abstract classes? Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance)
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: bstract classes? Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance)
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: Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance)
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: Interface allows multiple inheritance. Interface allows multiple inheritance.
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: Yes, starting from C# 8, interfaces can have default method implementations. 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, abstract classes can have fully implemented methods along with abstract methods.
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, 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; } }
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, 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
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
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 be injected as service contracts, but interfaces are preferred for looser 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: Both can define contracts for derived classes. Both support polymorphism. Both cannot be instantiated directly. Both can be used with dependency injection.
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: Interface contracts are pure method signatures. Abstract class contracts can contain shared code and fields.
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 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
{
public override void Start() => Console.WriteLine("Car started"); }
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 can only inherit other interfaces.
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: Yes, abstract classes can implement interfaces partially or fully.
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: 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.
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 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.
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 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.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.