Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Unit testing involves testing the smallest parts of an application (units) independently to ensure they work correctly. It is important because it helps detect bugs early, improves code quality, supports re…
Short answer: Unit Testing: Tests individual units in isolation. Integration Testing: Tests interaction between multiple components or systems. Functional Testing: Tests end-to-end functionality from the user's perspecti…
Short answer: Assertions verify that the actual outcome of a test matches the expected result, determining if a test passes or fails. Real-world example (ShopNest) Arrange a cart with 2 items → Act Checkout() → Assert to…
Short answer: Code coverage measures the percentage of code executed by tests. It helps identify untested parts but doesn’t guarantee test quality. High coverage with meaningful tests improves confidence in code correctn…
Short answer: xUnit is a free, open-source unit testing framework for .NET, designed by the original authors of NUnit. It’s popular because it supports modern testing practices, is lightweight, extensible, integrates wel…
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: 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: 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: 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: 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: 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…
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…
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…
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: 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: High-level modules should not depend on low-level modules. Both should depend on abstractions. Interfaces allow decoupling and easier testing. interface ILogger { void Log(string message); } Example code cl…
Short answer: ffect it? Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior. Real-world example (ShopNest) ShopNest has a…
Short answer: Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior. Real-world example (ShopNest) ShopNest has a base Payme…
Short answer: Duck typing: "If it looks like a duck and quacks like a duck, it is a duck." Behavior is based on method/property availability, not type inheritance. C# does not support full dynamic duck typing,…
Short answer: Allows interfaces to provide default method implementations. Reason: Enables adding new methods to interfaces without breaking existing implementations. interface IPrinter Example code { void Print(string m…
Unit Testing C# Programming Tutorial · Testing
Short answer: Unit testing involves testing the smallest parts of an application (units) independently to ensure they work correctly. It is important because it helps detect bugs early, improves code quality, supports refactoring, and provides documentation for expected behavior.
ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.
Unit Testing C# Programming Tutorial · Testing
Short answer: Unit Testing: Tests individual units in isolation. Integration Testing: Tests interaction between multiple components or systems. Functional Testing: Tests end-to-end functionality from the user's perspective.
ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.
Unit Testing C# Programming Tutorial · Testing
Short answer: Assertions verify that the actual outcome of a test matches the expected result, determining if a test passes or fails.
Arrange a cart with 2 items → Act Checkout() → Assert total and that payment was called once.
Unit Testing C# Programming Tutorial · Testing
Short answer: Code coverage measures the percentage of code executed by tests. It helps identify untested parts but doesn’t guarantee test quality. High coverage with meaningful tests improves confidence in code correctness. xUnit Framework
ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.
Unit Testing C# Programming Tutorial · Testing
Short answer: xUnit is a free, open-source unit testing framework for .NET, designed by the original authors of NUnit. It’s popular because it supports modern testing practices, is lightweight, extensible, integrates well with .NET Core and Visual Studio, and encourages clean, maintainable test code.
ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.
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: 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: 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: 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: 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: A method declared with abstract without implementation. Must be overridden in a derived class. abstract class Vehicle {
public abstract void Start();
}
class Car : Vehicle
{
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: llow derived class to optionally override
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 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
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 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: 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: High-level modules should not depend on low-level modules. Both should depend on abstractions. Interfaces allow decoupling and easier testing. interface ILogger { void Log(string message); }
class FileLogger : ILogger { public void Log(string message) => Console.WriteLine("File: " + message); } class UserService
{
private readonly ILogger _logger;
public UserService(ILogger logger) { _logger = logger; }
}
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: ffect it? Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior.
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: Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior.
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: Duck typing: "If it looks like a duck and quacks like a duck, it is a duck." Behavior is based on method/property availability, not type inheritance. C# does not support full dynamic duck typing, but interfaces enable a similar concept by relying on contract-based behavior. Dynamic types in C# (dynamic) can also simulate duck typing. interface IFlyable { void Fly(); }
void MakeItFly(IFlyable obj) => obj.Fly(); // Any object implementing IFlyable works
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: Allows interfaces to provide default method implementations. Reason: Enables adding new methods to interfaces without breaking existing implementations. interface IPrinter
{ void Print(string msg); void PrintInfo(string msg) => Console.WriteLine("Info: " + msg); // Default }
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.