0% found this document useful (0 votes)
33 views2 pages

DotNet CSharp OOP Interview CheatSheet

.NET C# OOP Interview Cheat Sheet covers key OOP principles such as encapsulation, abstraction, inheritance, and polymorphism. It explains access modifiers, constructors, and the differences between abstract classes and interfaces. Additionally, it includes information on properties, static members, exception handling, and the distinction between classes and objects.

Uploaded by

riazhamza742
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

DotNet CSharp OOP Interview CheatSheet

.NET C# OOP Interview Cheat Sheet covers key OOP principles such as encapsulation, abstraction, inheritance, and polymorphism. It explains access modifiers, constructors, and the differences between abstract classes and interfaces. Additionally, it includes information on properties, static members, exception handling, and the distinction between classes and objects.

Uploaded by

riazhamza742
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

.

NET C# OOP Interview Cheat Sheet

* 1. OOP Principles

- Encapsulation - Binding data and methods that work on data within one unit.

- Abstraction - Hiding internal details and showing only essential features.

- Inheritance - Deriving a class from another class to promote code reuse.

- Polymorphism - One interface, many implementations (method overloading/overriding).

* 2. Access Modifiers

- public - Accessible from anywhere.

- private - Accessible only within the same class.

- protected - Accessible within the same class and derived classes.

- internal - Accessible within the same assembly.

* 3. Constructors

- Special method invoked when object is created.

- Can be default, parameterized, static, or copy constructor.

- Example: public MyClass(string name) { this.name = name; }

* 4. Inheritance

- Base class members are reused in derived class.

- Use ':' to inherit. Example: class Dog : Animal

- Support for single inheritance only in C# (no multiple inheritance).

* 5. Polymorphism

- Method Overloading - Same method name with different parameters.

- Method Overriding - Using 'virtual' and 'override' keywords.

- Example: public override void Speak() { Console.WriteLine("Bark"); }

* 6. Abstract Classes & Interfaces

- Abstract Class - Cannot be instantiated, can have method implementation.

- Interface - Only method signatures, implemented using 'interface' keyword.

- A class can inherit multiple interfaces, but only one abstract class.

* 7. Properties

- Used to access class fields with get and set accessors.


- Example: public string Name { get; set; }

* 8. Static Keyword

- Static members belong to the class, not instances.

- Useful for utility functions or shared data.

- Example: public static int Count = 0;

* 9. Exception Handling

- try { ... } catch(Exception ex) { ... } finally { ... }

- Always handle exceptions to avoid runtime errors.

- Use custom exceptions when needed.

* 10. Object and Class

- Class - Blueprint for creating objects.

- Object - Instance of a class.

- Use 'new' keyword to create an object: var car = new Car();

You might also like