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 1201–1225 of 4608

Career & HR topics

By tech stack

Popular tracks

Junior PDF
What is the use of properties in encapsulation?

Short answer: Properties provide controlled access to private fields. Enable validation, read-only/write-only access, and future flexibility. Example: private int score; Example code public int Score { get { return score…

Mid PDF
How does encapsulation differ from abstraction?

Short answer: Encapsulation → Hides internal data, focuses on data protection. Abstraction → Hides implementation details, focuses on simplifying complex systems. Real-world example (ShopNest) ShopNest’s Order keeps _ite…

Mid PDF
Give an example of encapsulation in C#.?

Short answer: Real-World Example: Bank Account Management public class BankAccount Example code { private string accountNumber; // private field private decimal balance; // private field public string AccountNumber { get…

Junior PDF
What is abstraction in OOP?

Short answer: Abstraction is the process of hiding the internal implementation details of a system and exposing only the essential features. It allows developers to focus on what an object does, not how it does it. Examp…

Mid PDF
Why is abstraction important?

Short answer: Simplifies complex systems by exposing only relevant functionality. Enhances maintainability, readability, and reusability of code. Reduces dependency on implementation details, making systems more flexible…

Mid PDF
How do you implement abstraction in C#?

Short answer: Using abstract classes or interfaces. Abstract classes can have abstract and non-abstract methods. Interfaces define method signatures only. abstract class Vehicle { public abstract void Start(); } interfac…

Mid PDF
What are abstract classes?

Short answer: Classes that cannot be instantiated directly and may contain abstract methods (without implementation). Can have fields, constructors, and concrete methods. abstract class Animal { public abstract void Make…

Mid PDF
What are interfaces?

Short answer: Interfaces define a contract of methods, properties, or events that implementing classes must follow. Interfaces provide full abstraction without any implementation (C# 8+ allows default methods). interface…

Mid PDF
How do interfaces support abstraction?

Short answer: By exposing method signatures only, interfaces hide the implementation. Allows multiple classes to implement the interface differently, providing flexibility and decoupling. class Bird : IFlyable Example co…

Junior PDF
What is the difference between interface-based and abstract class-based abstraction?

Short answer: Feature Abstract Class Interface Methods Can have abstract + concrete methods Only abstract methods (C# 8+ allows default implementation) Fields Can have fields Cannot have fields Inheritance Single inherit…

Mid PDF
Can you instantiate an abstract class?

Short answer: No, abstract classes cannot be instantiated directly. Must be inherited by a derived class which implements abstract methods. abstract class Shape { public abstract void Draw(); } // Shape s = new Shape();…

Mid PDF
Can abstract classes have constructors?

Short answer: Yes, abstract classes can have constructors. Used to initialize fields for derived classes. abstract class Vehicle { Example code public string Brand; public Vehicle(string brand) { Brand = brand; } } class…

Mid PDF
Can abstract classes have non-abstract methods?

Short answer: Yes, abstract classes can have concrete methods with implementation. Allows shared behavior for derived classes. abstract class Animal { Example code public void Sleep() => Console.WriteLine("Sleepi…

Junior PDF
What is the purpose of abstraction in large systems?

Short answer: Reduces system complexity by focusing on essential features. Decouples modules, making large systems easier to maintain and extend. Promotes code reuse and flexibility. Real-world example (ShopNest) Checkou…

Mid PDF
How does abstraction reduce complexity?

Short answer: Hides implementation details, exposing only what is necessary. Users interact with interfaces or abstract methods, not the full system logic. Simplifies testing, maintenance, and understanding of code. Real…

Mid PDF
Give an example of abstraction in C#.?

Short answer: Real-World Example: Payment Processing // Abstract class abstract class Payment { public override void Pay(decimal amount) => Console.WriteLine($"Paid {amount:C} using PayPal"); } // Usage Paym…

Junior PDF
What is the base class and derived class?

Short answer: Base Class (Parent) → Class whose members are inherited. Derived Class (Child) → Class that inherits from base class. class Vehicle { public void Start() {} } // Base Example code class Car : Vehicle {} //…

Mid PDF
How is inheritance implemented in C#?

Short answer: Using the colon (:) symbol. Derived class can access public/protected members of the base class. class Vehicle { public void Start() => Console.WriteLine("Start"); } Example code class Car : Ve…

Mid PDF
Can you inherit multiple classes in C#?

Short answer: No, C# does not support multiple class inheritance to avoid ambiguity. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . UpiPayment and CardPayment override the fe…

Junior PDF
What is the workaround for multiple inheritance in C#?

Short answer: Use interfaces to achieve multiple inheritance. A class can implement multiple interfaces. interface IFlyable { void Fly(); } interface IDriveable { void Drive(); } class FlyingCar : IFlyable, IDriveable {…

Junior PDF
What is the difference between inheritance and composition?

Short answer: Feature Inheritance Composition Relationship "is-a" "has-a" Reuse Derived class reuses base class Object contains other objects Flexibility Less flexible More flexible Example: Inheritan…

Junior PDF
What is method overriding?

Short answer: A derived class provides a new implementation of a base class method marked virtual. Achieves run-time polymorphism. class Vehicle { public virtual void Start() => Console.WriteLine("Vehicle starts&…

Junior PDF
What is the use of the virtual and override keywords?

Short answer: virtual → Marks a base class method as overridable. override → Overrides a virtual method in the derived class. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . U…

Junior PDF
What is the sealed keyword?

Short answer: Prevents a class from being inherited or a method from being overridden. sealed class FinalClass { } class Car : FinalClass { } // Not allowed Real-world example (ShopNest) Think of ShopNest’s Product , Car…

Junior PDF
What is the difference between new and override in inheritance?

Short answer: override → Overrides a virtual method in base class (runtime polymorphism). new → Hides a base class method (compile-time hiding, not true overriding). class Vehicle { public void Start() => Console.Writ…

C# OOP C# Programming Tutorial · OOP

Short answer: Properties provide controlled access to private fields. Enable validation, read-only/write-only access, and future flexibility. Example: private int score;

Example code

public int Score
{ get { return score; } set { if (value >= 0) score = value; } // validation
}

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: Encapsulation → Hides internal data, focuses on data protection. Abstraction → Hides implementation details, focuses on simplifying complex systems.

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: Real-World Example: Bank Account Management public class BankAccount

Example code

{
private string accountNumber; // private field
private decimal balance; // private field
public string AccountNumber { get { return accountNumber; } } // read-only public decimal Balance { get { return balance; } } // read-only public BankAccount(string accNum, decimal initialBalance)
{
accountNumber = accNum; balance = initialBalance >= 0 ? initialBalance : throw new ArgumentException("Invalid balance"); }
public void Deposit(decimal amount)
{
if(amount > 0) balance += amount; else throw new ArgumentException("Deposit must be positive"); }
public void Withdraw(decimal amount)
{
if(amount > 0 && amount <= balance) balance -= amount; else throw new InvalidOperationException("Insufficient balance"); }
} // Usage BankAccount myAccount = new BankAccount("ACC123", 1000); myAccount.Deposit(500); // Balance becomes 1500 myAccount.Withdraw(200); // Balance becomes 1300 Console.WriteLine($"Account: {myAccount.AccountNumber}, Balance: {myAccount.Balance}"); Explanation: accountNumber and balance are private, protecting sensitive data. Controlled access via methods ensures data integrity. Demonstrates real-world encapsulation in action.

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: Abstraction is the process of hiding the internal implementation details of a system and exposing only the essential features. It allows developers to focus on what an object does, not how it does it.

Example code

A Vehicle class exposes Start() method without revealing engine details.

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: Simplifies complex systems by exposing only relevant functionality. Enhances maintainability, readability, and reusability of code. Reduces dependency on implementation details, making systems more flexible.

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: Using abstract classes or interfaces. Abstract classes can have abstract and non-abstract methods. Interfaces define method signatures only. abstract class Vehicle { public abstract void Start(); } interface IDriveable { void Drive(); }

Example code

Using abstract classes or interfaces. Abstract classes can have abstract and non-abstract methods. Interfaces define method signatures only. abstract class Vehicle {
public abstract void Start();
}
interface IDriveable
{ void 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: Classes that cannot be instantiated directly and may contain abstract methods (without implementation). Can have fields, constructors, and concrete methods. abstract class Animal { public abstract void MakeSound(); public void Sleep() => Console.WriteLine("Sleeping"); }

Example code

Classes that cannot be instantiated directly and may contain abstract methods (without implementation). Can have fields, constructors, and concrete methods. abstract class Animal {
public abstract void MakeSound();
public void Sleep() => Console.WriteLine("Sleeping");
}

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 define a contract of methods, properties, or events that implementing classes must follow. Interfaces provide full abstraction without any implementation (C# 8+ allows default methods). interface IFlyable

Example code

{ void Fly(); }

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: By exposing method signatures only, interfaces hide the implementation. Allows multiple classes to implement the interface differently, providing flexibility and decoupling. class Bird : IFlyable

Example code

{
public void Fly() => Console.WriteLine("Bird is flying");
}
class Airplane : IFlyable
{
public void Fly() => Console.WriteLine("Airplane is 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: Feature Abstract Class Interface Methods Can have abstract + concrete methods Only abstract methods (C# 8+ allows default implementation) Fields Can have fields Cannot have fields Inheritance Single inheritance Multiple interfaces can be implemented Constructo Can have constructors Cannot have constructors

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: No, abstract classes cannot be instantiated directly. Must be inherited by a derived class which implements abstract methods. abstract class Shape { public abstract void Draw(); } // Shape s = new Shape(); // Not allowed

Example code

class Circle : Shape { public override void Draw() => Console.WriteLine("Circle"); }

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 constructors. Used to initialize fields for derived classes. abstract class Vehicle {

Example code

public string Brand;
public Vehicle(string brand) { Brand = brand; }
}
class Car : Vehicle
{
public Car(string brand) : base(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 have concrete methods with implementation. Allows shared behavior for derived classes. abstract class Animal {

Example code

public void Sleep() => Console.WriteLine("Sleeping");
public abstract void MakeSound();
}

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: Reduces system complexity by focusing on essential features. Decouples modules, making large systems easier to maintain and extend. Promotes code reuse and flexibility.

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: Hides implementation details, exposing only what is necessary. Users interact with interfaces or abstract methods, not the full system logic. Simplifies testing, maintenance, and understanding of code.

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: Real-World Example: Payment Processing // Abstract class abstract class Payment { public override void Pay(decimal amount) => Console.WriteLine($"Paid {amount:C} using PayPal"); } // Usage Payment payment1 = new CreditCardPayment(); payment1.Pay(500); payment1.ShowReceipt(500); Payment payment2 = new PayPalPayment(); payment2.Pay(300); payment2.ShowReceipt(300); Explanation: Payment defines what a payment should do…

Explain a bit more

(abstract method Pay). Derived classes (CreditCardPayment, PayPalPayment) define how payment is made. Users interact only with the abstract interface, not the internal logic.

Example code

public abstract void Pay(decimal amount);
public void ShowReceipt(decimal amount) => Console.WriteLine($"Paid: {amount:C}"); } // Derived classes implement abstraction class CreditCardPayment : Payment
{
public override void Pay(decimal amount) => Console.WriteLine($"Paid {amount:C} using Credit Card"); }
class PayPalPayment : Payment
{

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: Base Class (Parent) → Class whose members are inherited. Derived Class (Child) → Class that inherits from base class. class Vehicle { public void Start() {} } // Base

Example code

class Car : Vehicle {} // Derived

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: Using the colon (:) symbol. Derived class can access public/protected members of the base class. class Vehicle { public void Start() => Console.WriteLine("Start"); }

Example code

class Car : Vehicle { }
Car myCar = new Car(); myCar.Start(); // Inherited method

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: No, C# does not support multiple class inheritance to avoid ambiguity.

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: Use interfaces to achieve multiple inheritance. A class can implement multiple interfaces. interface IFlyable { void Fly(); } interface IDriveable { void Drive(); } class FlyingCar : IFlyable, IDriveable { public void Fly() {} public void Drive() {} }

Example code

Use interfaces to achieve multiple inheritance. A class can implement multiple interfaces. interface IFlyable { void Fly(); }
interface IDriveable { void Drive(); }
class FlyingCar : IFlyable, IDriveable { public void Fly() {} public void Drive() {} }

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 Inheritance Composition Relationship "is-a" "has-a" Reuse Derived class reuses base class Object contains other objects Flexibility Less flexible More flexible Example: Inheritance → Car is a Vehicle Composition → Car has a Engine

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: A derived class provides a new implementation of a base class method marked virtual. Achieves run-time polymorphism. class Vehicle { public virtual void Start() => Console.WriteLine("Vehicle starts"); } class Car : Vehicle { public override void Start() => Console.WriteLine("Car starts"); }

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: virtual → Marks a base class method as overridable. override → Overrides a virtual method in the derived class.

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: Prevents a class from being inherited or a method from being overridden. sealed class FinalClass { } class Car : FinalClass { } // Not allowed

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: override → Overrides a virtual method in base class (runtime polymorphism). new → Hides a base class method (compile-time hiding, not true overriding). class Vehicle { public void Start() => Console.WriteLine("Vehicle");

Example code

}
class Car : Vehicle { public new void Start() => Console.WriteLine("Car"); }

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