Menu

Access modifiers (OOP Concepts in C#)
πŸ“°

Access modifiers (OOP Concepts in C#)

DEV Community: dotnetΒ·DIVAKAR UPADHYAYΒ·about 3 hours ago
#4dldzi1R
#devtodotnet#devto#dev#class#derived
Long article (326 words) β€” no AI summary yet.
Reading 0:00
15s threshold

πŸ‘‰ Full lesson with practice questions on DevLadder (free, lesson 3 of 15 in the OOP Concepts in C# course)

Modifier Accessible from

public Everywhere

private Same class only (default for class members)

protected Same class and derived classes

internal Same assembly (default for top-level types)

protected internal Same assembly or derived classes anywhere

private protected Derived classes in the same assembly only

file (C# 11) Same source file (for types)

Interview tip: the default access for class members is private ; for a top-level class it is internal .

Interview questions on OOP Concepts in C

What are the four pillars of OOP? Explain each with an example.

Encapsulation : private state with a controlled public API. BankAccount keeps _balance private and exposes Deposit() that rejects negative amounts.

Abstraction : expose what , hide how . IPaymentGateway.ChargeAsync() hides HTTP calls, signatures and retries.

Inheritance : a derived class reuses and extends a base.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.