0% found this document useful (0 votes)
1 views12 pages

Oops

The document discusses various concepts in C# programming, including abstract and sealed classes, the significance of private and protected constructors, and the differences between private and static constructors. It also explains the purpose of constructors and properties, as well as key object-oriented principles such as inheritance, polymorphism, abstraction, and encapsulation. Additionally, it touches on concepts like late binding, early binding, and duck typing.

Uploaded by

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

Oops

The document discusses various concepts in C# programming, including abstract and sealed classes, the significance of private and protected constructors, and the differences between private and static constructors. It also explains the purpose of constructors and properties, as well as key object-oriented principles such as inheritance, polymorphism, abstraction, and encapsulation. Additionally, it touches on concepts like late binding, early binding, and duck typing.

Uploaded by

Merlin
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

OOPS

General

Abstract Class

Sealed Class

Abstract and Sealed Classes and Class Members - C# Programming Guide - C# | Microsoft Learn

What is the Significance of Private Constructor?


A private constructor is a special instance constructor. If a class has one or more private
constructors and no public constructors, other classes cannot create instances of this class

If you do not use an access modifier with the constructor, it will still be private by default.

Private Constructors - C# Programming Guide - C# | Microsoft Learn

What is the significance of Protected Constructor?

What are the differences between Private Constructor and Static Constructor?
Why do we need properties?
Every class has a constructor though we do not create it. Constructor is a method with the name as the
class name and has no return type

What is virtual method?


Virtual method is used to implement late binding. It would allow the subclasses of the type to override the
method

Note:

1. Constructors cannot be virtual, while destructors can be virtual


2. Class’ default constructor is invoked when the class is created
3. Constructors are called in order from base class whereas destructors are called from in order
from derived classes

When do we need constructors and when do we need properties?


Constructors are used to initialize some of the fields which are mandatory while inserting the record into a
table e.g. Employee Id

Properties are used to set values that changes in an object based on some logic e.g. salary
Object Oriented Principle

1. Inheritence
2. Polymorphism
3. Abstraction
4. Encapsulation

Reference:
C# Design Patterns - step by step - made easy for Beginners. - YouTube

Late Binding
Early Binding
DuckTyping

You might also like