Mid From PDF OOP C# OOP

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 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.
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