PCBWay

1. What is OOPS?

DRex Electronics

OOPS is abbreviated as Object Oriented Programming System in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.

2. What are the advantages of OOPS?

  • It provides a simple way to solve complex problems.
  • It provides a clear modular structure in which each object exists independently.
  • Objects are reusable in other programs.
  • It makes software easier to maintain. Since the design is modular, part of the system can be updated in case of issues without a need to make large-scale changes

3. What is the difference between OOP and SOP?

Object-Oriented Programming Structural Oriented Programming
In object-oriented programming,
the program is divided into small
parts called objects.
In procedural programming,
the program is divided into
small parts called functions.
Bottom-up approach Top-down approach
Object-oriented programming have
access specifiers like private,
public, protected, etc
There is no access specifier in
procedural programming.
In object-oriented programming,
data is more important than function.
In procedural programming, the
function is more important than data.
Provides data hiding Does not provide data hiding

4. What are the basic concepts of OOPS?

  • Abstraction.
  • Encapsulation.
  • Inheritance.
  • Polymorphism.

5. What is an abstraction and why is it important?

Abstraction is the process of representing essential features by hiding the background details/process. In other words, it speaks about what to do rather than how to do it.

6. What is Encapsulation?

Encapsulation means that a group of related properties, methods, and other members are treated as a single unit or object.

It is a technique to hide the properties and behaviors of an object. It prevents other objects from altering or accessing the properties of an encapsulated object.

7. How encapsulation is implemented in C#?

Encapsulation is implemented by using access specifiers.

8. What is the purpose of an access specifier in C#?

An access specifier defines the scope and visibility of a class member.

9. What is a class?

A class is a representation of a type of object. It is the blueprint or template that describes the details of an object.

10. What is the default access specifier for a class?

The default access specifier for a class type is internal.

11. What is an object?

An object is termed as an instance of a class, and it has its own state, behavior, and identity.

You can easily understand the concept of class and object by the following example: In the above example car is a basic template. Based on the car template different car brands(objects) are manufactured.

12. What is the difference between Class and Object?

Class Object
Class is a template for creating
an object within a program
The object is an instance of a class
Logical entity Physical entity
Declared with a keyword “class” Created with the “new” keyword
Memory is not allocated while creating a class It can be manipulated
A class is declared once Multiple objects can be created for a class
A class is declared once Multiple objects can be created for a class

13. What is Polymorphism?

The word polymorphism means having many forms. In object-oriented programming, it is expressed as ‘one interface, multiple functions’.

Example: Here the same person behaves differently in different places. This is called polymorphism.

14. What are the types of polymorphism?

  • Compile-time polymorphism (also called as static polymorphism)
  • Run time polymorphism (also called as dynamic polymorphism)

15. What is early binding or static binding?

The mechanism of linking a function with an object during compile time is called early binding or static binding.

16. What are the techniques provided by C# to implement static polymorphism?

C# provides two techniques to implement static polymorphism. They are

  • Function overloading
  • Operator overloading

17. What is function overloading?

Function overloading is a C# feature, where more than one method can have the same name but different parameters. So that function works differently based on parameter.

Example: You have a function Sum() that accepts values as a parameter and prints their addition. You can write multiple functions with name Sum() but the parameter signature must be different.

18. What are the different ways for a method to be overloaded?

A method can be overloaded by:

  • Varying the numbers of parameters
  • Using different data types for the parameters
  • Using a different sequence of the parameters.

19. Is there any limitation for method overloading?

There is no limitation for method overloading, you can create any number of methods with the same name and different signatures

20. What is operator overloading?

Operator overloading gives the ability to use the same operator to do various operations. Not all operators can be overloaded, however, and others have restrictions, as listed in this table:

21. What is the real-time example of the function overloading?

Assume that you’ve to describe your day. This will be a function called ‘talk’.

a) Imagine that you’re describing your day to a Stranger. In this case, you will keep it short and will not include many details. The function ‘talk’ will be a short one.

b) Imagine that you’re describing the same day to your Manager. In this case, you will describe the events of the day in a more detailed manner than you’ve described to a stranger. The function ‘talk’ will be a long one.

What has happened here?

You’ve performed the same function ‘talk’ (Describe your day), but based on the parameter (the participant on the other side – Stranger/Manager), the way of implementing the function (describing the day) has changed!

class You
{
void talk (stranger obj)
{
console.Writeline (“Hi, my day was great!”);
}
void talk(Manager obj)
{
console.Writeline(“Dear Sir, Today, I have completed 5 tasks out of 10. I will complete remaining tomorrow.”);
}

}

22. What is method overriding?

There can be two methods with the same name and signature but different implementation. The function here is resolved during run time rather than compile time. This is called method overriding.

23. What is dynamic or run-time polymorphism?

Method overriding is called as dynamic or run time polymorphism

24. What is the difference between method overloading and method overriding?

You can understand the difference between overloading and overriding by the below diagram simply.

The difference between method overloading and method overriding is:

Method Overloading Method Overriding
Method overloading is the
compile-pile-time polymorphism.
It is run time polymorphism
It occurs within the same class It occurs between the two classes
(i.e., parent class and child class)
inheritance not involved Inheritance
involved
Inheritance not involved Inheritance involved
One method does not hide another method Child method hides the method of the parent
The parameter must be different The parameter must be the same
Return type may or may not be same The return type must be the same

25. When do you use the overload method in C# and when do you use override?

If you see a different implementation of a class has a different way of doing a certain thing than overriding is the way to go while overloading is doing the same thing but with different input. method signature varies in case of overloading but not in case of overriding in C#.

26. What is Inheritance?

Inheritance is one of the fundamental attributes of object-oriented programming. It allows you to define a child class that reuses (inherits), extends, or modifies the behavior of a parent class. i.e. when we want to create a new class and there is already a class that includes some of the code that we want, we can derive our new class from the existing class.

By doing this, we are reusing the fields and methods of the existing class.

Example:

Dog, Cat, Cow can be Derived Class of Animal base class. They inherit the common behaviors of the animal base class.

27. What is a base class and derived class?

The class whose features are inherited is known as a base class (or a parent class).

The class that inherits the members of the base class is called the derived class. The derived class can add its own fields and methods in addition to the base class fields and methods.

28. What are the types of inheritance?

  • Single Inheritance
  • Multilevel Inheritance
  • Hierarchical Inheritance
  • Multiple Inheritance
  • Hybrid Inheritance

29. What is single inheritance?

In single inheritance, subclasses inherit the features of one superclass. In the image below, class A serves as a base class for the derived class B.

30. What is Multilevel Inheritance?

In Multilevel Inheritance, a derived class will be inheriting a base class and as well as the derived class also act as the base class to other class. In the below image, class A serves as a base class for the derived class B, which in turn serves as a base class for the derived class C.

31. What is Hierarchical Inheritance?

In Hierarchical Inheritance, one class serves as a superclass (base class) for more than one subclass. In the below image, class A serves as a base class for the derived classes B, C, and D.

32. What is multiple inheritance?

In Multiple inheritance, one class can have more than one superclass and inherit features from all its parent classes.

33. What is hybrid inheritance?

Hybrid Inheritance is implemented by combining more than one type of inheritance. The below image shows Combining Hierarchical inheritance and Multiple Inheritance.

34. What is a constructor?

A constructor is a method used to initialize the state of an object, and it gets invoked at the time of object creation. Rules for constructor are:

  • Constructor Name should be the same as the class name.
  • The constructor must have no return type.

35. What are the types of constructors?

a) Default Constructor

b) Parameterized constructor

c) Static constructor

d) Copy constructor

36. What is the default constructor?

A constructor without any parameters is called a default constructor. In other words, this type of constructor does not take parameters.

If you don’t provide a constructor for your class, C# creates one by default that instantiates the object and sets member variables to the default values as listed in the Default Values Table.

37. What is a Parameterized constructor?

A constructor having a specific number of parameters(arguments) is called a parameterized constructor.

38. What is a Static constructor?

A static constructor is used to initialize any static data, or to perform a particular action that needs to be performed once only. It is called automatically before the first instance is created or any static members are referenced.

39. Is the Static constructor take access modifier and parameter?

A static constructor does not take access modifiers or have parameters.

40. Can a static constructor be inherited or overloaded?

Static constructors cannot be inherited or overloaded.

41. Can you call a static constructor directly?

A static constructor cannot be called directly and is only meant to be called by the common language runtime (CLR). It is invoked automatically.

The user has no control over when the static constructor is executed in the program.

42. How is the static constructor called?

A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.

A static constructor will run before an instance constructor.

A type’s static constructor is called when a static method assigned to an event or a delegate is invoked and not when it is assigned. If static field variable initializers are present in the class of the static constructor, they will be executed in the textual order in which they appear in the class declaration immediately before the execution of the static constructor.

43. If you don’t provide a static constructor to initialize static fields, what will happen?

If you don’t provide a static constructor to initialize static fields, all static fields are initialized to their default value as listed in Default values of C# types

Type Default value
Any reference type Null
Any built-in integral numeric type 0
Any built-in floating-point numeric type 0
bool false
Char ‘\0’ (U+0000)
enum The value produced by the expression
(E)0, where E is the enum identifier.
struct An instance for which the HasValue
property is false and the Value
property is undefined. That default
value is also known as the null value
of a nullable value type.

44. What is the usage of static constructor?

A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.

Static constructors are also useful when creating wrapper classes for unmanaged code when the constructor can call the Load Library method.

Static constructors are also a convenient place to enforce run-time checks on the type parameter that cannot be checked at compile-time via constraints (Type parameter constraints).

45. What is a Copy constructor?

The constructor which creates an object by copying variables from another object is called a copy constructor. The purpose of a copy constructor is to initialize a new instance to the values of an existing instance.

46. Define Destructor?

A Destructor has the same name as the class with a tilde character and is used to destroy an instance of a class.

47. Give an example for destructor?

If you observe the above example, we created a class with a default constructor and destructor. Here we created an instance of class “User” in Details() method and whenever the Details function execution is done, then the garbage collector (GC) automatically will invoke a destructor in User class to clear the object of a class. When you execute the above c# program, you will get the result as shown below.

48. Can a class have more than one destructor?

No, a class can have only 1 destructor.

49. Can struct in C# have a destructor?

No, structs can have constructors but not destructors, only classes can have destructors.

50. Can you pass parameters to destructors?

No, you cannot pass parameters to destructors. Hence, you cannot overload destructors.

51. Can you use an access modifier in destructors?

The destructor does not take modifiers.

52. Can you call the destructor?

Destructors cannot be called. They are invoked automatically.

53. Why the programmer has no control in the destructor?

The Programmer has no control over when the destructor is called because this is determined by Garbage Collector.

54. How is the destructor executed?

Destructor is called when the program exits.

Execution of the destructor for the instance may occur at any time after the instance becomes eligible for destruction.

Destructor implicitly calls Finalize on the base class of object.

55. Can you explicitly call a destructor?

No, you cannot explicitly call a destructor. Destructors are invoked automatically by the garbage collector.

56. Why it is not a good idea to use empty destructors?

When a class contains a destructor, an entry is created in the Finalize queue. When the destructor is called, the garbage collector is invoked to process the queue. If the destructor is empty, this just causes a needless loss of performance.

57. What is the difference between structure and a class?

Structure Class
The structure is a collection of
different types of data types.
Class is a group of common objects
that share common properties and
relationships.
It is a value type It is a reference type
An object for the structure is created
on the stack memory.
An object for the class is created
on the heap memory.
It cannot be inherited Classes can be inherited
The member variable of structure
cannot be initialized directly
The member variable class can be
initialized directly
It can have only parameterized
constructor
It can have all type of constructor and
destructor
Structure members are public by default Class members are private by default

58. What are Access Modifiers?

  • Access Modifiers are keywords in C#
  • They are used to restrict the viability of object, method, class, and its members into the program or in application”.
  • We can control the scope of the member object of a class using access specifiers which are used to provide security of applications

59. What are the Types of Access Modifiers?

  • Public
  • Private
  • Protected
  • Internal
  • Protected internal

60. What is a Public access modifier?

  • It is the most used access specifier in C#.
  • It can be accessed from anywhere, which means there is no restriction on accessibility.
  • The scope of the accessibility is inside a class as well as outside of the class.
  • The type or member can be accessed by any other code in the same assembly or another assembly that references it.

61. What is the limitation of a Public access modifier?

The members of public access specifier can be accessed

  • Within the class in which they are declared.
  • Within the derived classes of that class available within the same assembly.
  • Outside the class within the same assembly.
  • Within the derived classes of that class available outside the assembly.
  • Outside the class outside the assembly.

62. What is the scope of Private access modifier?

The scope of the accessibility is limited only inside the classes or struct in which they are declared.

63. What is the scope of a protected access modifier?

The members of Protected access specifier can be accessed

  • Within the class in which they are declared.
  • Within the derived classes of that class available within the same assembly.
  • Within the derived classes of that class available outside the assembly.

64. What is Internal?

The internal access modifiers can access within the program that contains its declarations and also access within the same assembly level but not from another assembly.

The members of the Internal access specifier can be accessed

  • within the class in which they are declared.
  • within the derived classes of that class available within the same assembly.
  • Outside the class within the same assembly.

65. What is Protected Internal?

Protected internal is the same access levels of both protected and internal. It can access anywhere in the same assembly and the same class also the classes inherited from the same class.

The members of protected Internal access specifier can be accessed

  • Within the class in which they are declared.
  • Within the derived classes of that class available within the same assembly.
  • Outside the class within the same assembly.
  • Within the derived classes of that class available outside the assembly.

66. What is the default access modifier for class, struct, Interface, Enum, Delegate?

The default access modifier for class, struct, Interface, Enum, Delegate is Internal.

67. What is the default access modifier for a namespace?

A namespace will not have an access modifier.

68. What is the default access modifier for class and struct members?

The default access modifier for class and struct members is private.

69. What is the default access modifier for interface members?

We cannot apply access modifiers to interface members. Always interface members are public.

70. What is the default access modifier for Enum members?

Enum members are always public and no access modifier can be applied

71. What are the types of Classes?

  • Abstract Class
  • Partial Class
  • Sealed Class
  • Static Class

72. What is an Abstract class?

An Abstract class is a class that provides a common definition to the subclasses and this is the type of class whose object is not created. Some key points of Abstract classes are:

  • Abstract classes are declared using the abstract keyword.
  • We cannot create an object of an abstract class. If you want to use it then it must be inherited in a subclass.
  • An Abstract class contains both abstract and non-abstract methods.
  • The methods inside the abstract class can either have an implementation or no implementation.
  • We can inherit two abstract classes; in this case, the base class method implementation is optional.
  • An Abstract class has only one subclass.
  • Methods inside the abstract class cannot be private.
  • If there is at least one method abstract in a class then the class must be abstract.

For example:

abstract class Accounts

{

}

73. What is a Partial Class?

It is a type of class that allows dividing their properties, methods, and events into multiple source files and at compile time these files are combined into a single class.

The following are some key points:

  • All the parts of the partial class must be prefixed with the partial keyword.
  • If you seal a specific part of a partial class then the entire class is sealed, the same as for an abstract class.
  • Inheritance cannot be applied to partial classes.
  • The classes that are written in two class files are combined at run time.

For example:

74. What is a Sealed Class?

A Sealed class is a class that cannot be inherited and used to restrict the properties.

The following are some key points:

  • A Sealed class is created using the sealed keyword.
  • Access modifiers are not applied to a sealed class.
  • To access the sealed members we must create an object of the class.

75. What is a Static Class?

It is the type of class that cannot be instantiated. In other words, we cannot create an object of that class using the new keyword, such that class members can be called directly using their class names.

The following are some key points:

  • Created using the static keyword.
  • Inside a static class, only static members are allowed, in other words, everything inside the static class must be static.
  • We cannot create an object of the static class.
  • A Static class cannot be inherited.
  • It allows only a static constructor to be declared.
  • The methods of the static class can be called using the class name without creating the instance.

For example:

static class Accounts

{

}

76. Why is access to non-static variables not allowed from static methods in C#?

We cannot access non-static data from static methods in C#. Because non-static variables are associated with a particular instance of an object while Static is not associated with any instance.

77. How can we protect a method from overriding in the derived class?

A derived class can stop virtual inheritance by declaring an override as sealed. Stopping inheritance requires putting the sealed keyword before the override keyword in the class member declaration. The following code provides an example:

78. How can you hide base class members with the new member in derived Class?

A derived class can hide base class members by declaring members with the same name and signature.

The new keyword is used to hide the base class member. The new keyword is put before the return type of a class member that is being replaced.

The use of new isn’t required, but a compiler warning will be generated if new isn’t used.

79. What is the condition to override a base class member?

A derived class can override a base class member only if the base class member is declared as virtual or abstract.

The derived member must use the override keyword to explicitly indicate that the method is intended to participate in virtual invocation. The following code provides an example:

Fields cannot be virtual; only methods, properties, events, and indexers can be virtual.

80. What is a virtual method?

A virtual method is a method that can be redefined in derived classes.

A virtual method has an implementation in a base class as well as derived the class.

It is used when a method’s basic functionality is the same, but sometimes more functionality is needed in the derived class.

A virtual method is created in the base class that can be overridden in the derived class.

We create a virtual method in the base class using the virtual keyword and that method is overridden in the derived class using the override keyword.

Example:

81. What is the difference between abstract and virtual?

A Virtual method must always have a default implementation. However, it can be overridden in a derived class by the keyword override.

An Abstract method doesn’t have any implementation. It resides in the abstract class, and also the derived class must implement the abstract class. The use of the override keyword is not necessary.

82. What is an interface?

An interface is typically like an abstract base class with only abstract members. Any class or struct that implements the interface must implement all its members. In other words, interface consists only method skeleton and no implementations.

83. What’s the naming convention of interface?

The interface name should start with an I.Example–IDisposable, IEnumerable

84. What is the use of the interface in C#?

  • Achieve/Support the Multiple Inheritance
  • Achieve loose coupling Code
  • Provides abstraction behaviors
  • Support extensible
  • Interfaces add a plug and play like architecture into your applications.
  • With interfaces, we can define a contract (agreement or blueprint) and provide it to the client.
  • Unit testing is possible. Create the mock or stub the class objects and pass it via interface
  • Implement Dependency injection

85. What is the difference between abstract class and interface?

Abstract Class Interface
An abstract class does not provide
a full abstraction
An interface does provide a full
abstraction
Using abstract we cannot achieve
multiple inheritances
Using an interface, we can achieve
multiple inheritances
Abstract class contains a data member An interface does not contain a data member
Abstract class contains a constructor An interface does not contain a constructor
An abstract class can contain access
modifiers for the functions and properties
We cannot use any access modifier in an
interface (Ex: public, private, protected,
internal, etc). Because within an interface
everything public by default
An abstract class can be defined An interface cannot be defined by using
the keyword static, sealed, virtual or abstract
A class can inherit only one abstract class A class can inherit several interfaces
An abstract class can contain an abstract
method and a non-abstract method
An interface can contain only abstract
methods. It provides signature only
An abstract class can provide the
implementation of an interface
Interface can’t provide the implementation
of an abstract class.

86. How can we achieve the Multiple Inheritance in C#?

We can achieve multiple inheritance in C# using the interface

87. When to use interface and when to use an abstract class?

An Abstract Class can be used in the following Scenarios:

  • When creating a class library that will be widely distributed or reused—especially to clients, use an abstract class in preference to an interface; because, it simplifies versioning. This is the practice used by the Microsoft team which developed the Base Class Library. (COM was designed around interfaces.)
  • Use an abstract class to define a common base class for a family of types.
  • Use an abstract class to provide default behavior.
  • Subclass only a base class in a hierarchy to which the class logically belongs.

An Interface can be used in the following Scenarios:

  • When creating a standalone project which can be changed at will, use an interface in preference to an abstract class; because, it offers more design flexibility.
  • Use interfaces to introduce polymorphic behavior without subclassing and to model multiple inheritance—allowing a specific type to support numerous behaviors.
  • Use an interface to design a polymorphic hierarchy for value types.
  • Use an interface when an immutable contract is intended.
  • A well-designed interface defines a very specific range of functionality. Split up interfaces that contain unrelated functionality.

88. What are design patterns?

Design patterns are reusable solutions to the common software problems that occur repeatedly in real-world application development.

They are templates or descriptions of how to solve problems that can be used in many situations.

These generalized patterns act as a template and they can be applied to solve real-time problems.

89. What are the categories in the design patterns?

There are 23 design patterns. They are also known as Gang of Four (GoF) design patterns. The Gang of Four is the authors of the book, “Design Patterns: Elements of Reusable Object-Oriented Software”. These 23 patterns are grouped into three main categories:

  1. Creational Design Patterns
  2. Structural Design Patterns
  3. Behavioural Design Patterns

90. What is Creational?

This type of design pattern deals with object creation and initialization mechanisms, trying to create objects in a manner suitable to the situation.

91. What is structural?

Structural Patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities. This pattern mainly focuses on decoupling the interface and implementation of classes and their objects.

92. What is Behavioural?

Behavioral pattern deals with communication between class objects.

93. Explain the singleton design pattern?

Singleton design pattern is used when we need to ensure that only one object of a class needs to be created.

Example:

94. How can you identify a singleton pattern?

Singleton can be identified by a static creation method, which returns the same cached object.

95. Give an example of a singleton pattern?

  • Reading configuration files that should only be read at start-up time and encapsulating them in a Singleton.
  • Use a singleton when you need to manage a shared resource. For instance, a printer spooler. Your application should only have a single instance of the spooler to avoid conflicting requests for the same resource.
  • A database connection or a file manager etc.

96. What are the differences between a static class and a singleton class?

Static Class Singleton Class
A static class cannot be a top-level class It can be a top-level class
It cannot implement an interface It can implement an interface
All members of a static class are static It is optional
A static class object is initialized
when it is loaded. So, it cannot
be lazily loaded
It is lazily loaded
A static class object is stored in a stack Singleton class object is stored in heap

97. What is the factory pattern?

The factory pattern is one of the most used design patterns in C#.

In the factory pattern, we create an object without exposing the creation logic. An interface is used for creating an object, but let’s subclass decide which class to instantiate. Rather than defining each object manually, developers can do it programmatically.

In other words, a factory is an object that creates objects without the use of a constructor.

98. When will you use the factory design pattern?

We can choose the factory pattern when

  1. The object needs to be extended to subclasses
  2. The classes don’t know what exact sub-classes it has to create
  3. The product implementation tends to change over time and the clients remain unchanged

99. Explain the factory pattern with example?

The classes and objects used in factory pattern are classified as follows:

  • Product
  • Concrete Product
  • Creator
  • Concrete Creator

Assume you have three different cards which are considered here as classes MoneyBack, Titanium, and Platinum, all of them implement abstract class CreditCard. You need to instantiate one of these classes, but you don’t know which of them, it depends on the user. This is a perfect scenario for the Factory Method design pattern.

Example:

Product:

Concrete Product (MoneyBackCreditCard)

Concrete Product (TitaniumCreditCard)

Concrete Product (PlatinumCreditCard)

Creator:

Concrete Creator:

Call factory classes:

Output:

100. What is an abstract design pattern?

Abstract Factory is a creational design pattern that lets you produce families of related objects without specifying their concrete classes.

101. What is a Builder design pattern?

A builder pattern builds a complex object using simple objects.

It helps us to separate the construction of the complex objects from its representation so that the same construction process can create different representations.

102. What are the sections available in the builder pattern?

To achieve decoupling of the construction process from the representation the builder pattern divided into three sections

  • Builder
  • Director
  • Product

Builder

The builder is responsible for defining the construction process for individual parts.  The builder has those individual processes to initialize and configure the product.

Director

Director takes those individual processes from the builder and defines the sequence to build the product.

Product

Product is the final object which is produced from the builder and director coordination.

103. Give an example of a builder design pattern?

Product

Builder

Director class

Class Output

104. What is a Prototype design pattern?

Prototype pattern refers to creating a duplicate object while keeping performance in mind. This pattern involves implementing a prototype interface that tells to create a clone of the current object.

105. When the Prototype pattern is to be used?

This pattern is used when the creation of an object directly is costly. For example, an object is to be created after a costly database operation. We can cache the object, returns its clone on the next request, and update the database as and when needed thus reducing database calls.

106. What is the adapter design pattern?

The adapter pattern works as a bridge between two incompatible interfaces. This pattern involves a single class that is responsible to join functionalities of independent or incompatible interfaces.

107. Give an example of an Adapter pattern?

A real-life example could be a case of a card reader which acts as an adapter between the memory card and a laptop. You plug in the memory card into the card reader and card reader into the laptop so that memory card can be read via the card reader.

108. What is a composite design pattern?

This pattern creates a class that contains a group of its objects. This class provides ways to modify its group of the same objects.

109. What is a proxy design pattern?

In a proxy pattern, a class represents the functionality of another class. In a proxy pattern, we create an object having an original object to interface its functionality to the outer world.

110. What is a flyweight design pattern?

The flyweight design pattern is used to reduce the number of objects created and reduce memory usage and increase performance. This pattern tries to reuse already created a similar kind  of object by storing them and create a new object when no matching object found

111. What is a facade design pattern?

Facade pattern hides the complexities of the system and provides an interface to the client using which the client can access the system. This pattern adds an interface to the existing system to hide its complexities.

This pattern involves a single class that provides simplified methods required by the client and delegates calls to methods of existing system classes.

112. What is a bridge design pattern?

This pattern decouples implementation class and abstract class by providing a bridge structure between them.

This pattern involves an interface that acts as a bridge which makes the functionality of concrete classes independent from interface implementer classes. Both types of classes can be altered structurally without affecting each other.

113. What is a decorator design pattern?

This pattern creates a decorator class that wraps the original class and provides additional functionality keeping class methods signature intact.

The decorator pattern allows a user to add new functionality to an existing object without altering its structure

114. What is a mediator design pattern?

This pattern provides a mediator class that normally handles all the communications between different classes.

It reduces the communication complexity between multiple objects or classes.

It easies the maintainability of the code by loose coupling.

115. What is a chain of responsibility design pattern?

The chain of responsibility pattern creates a chain of receiver objects for a request. This pattern decouples the sender and receiver of a request based on the type of request.

116. What is an observer design pattern?

The observer pattern is used when there is a one-to-many relationship between objects such as if one object is modified, its dependent objects are to be notified automatically.

117. What is a strategy design pattern?

In a Strategy pattern, a class behavior or its algorithm can be changed at run time.

118. What is a command design pattern?

In a Command Design Pattern, the request is wrapped under an object as command and passed to an invoker object. The invoker object looks for the appropriate object which can handle this command and passes the command to the corresponding object which executes the command.

119. What is a state design pattern?

In a State Design Pattern, a class behavior changes based on its state. In a State pattern, we create objects which represent various states and a context object whose behavior varies as its state object changes.

120. What is a visitor design pattern?

In the Visitor pattern, we use a visitor class which changes the execution algorithm of an element class. In this pattern, the execution algorithm of elements can different for different visitors.

121. What is an iterator design pattern?

This pattern is used to access the elements of a collection object sequentially without any need to know its underlying representation.

122. What is an interpreter design pattern?

Interpreter pattern provides a way to evaluate language grammar or expression. This type of pattern comes under behavioral patterns. This pattern involves implementing an expression interface that tells to interpret a context.

123. Give an example where the Interpreter pattern is used?

This pattern is used in SQL parsing, symbol processing engine, etc.

124. What is a memento design pattern?

Memento pattern is used to restore the state of an object to a previous state

125. What is Dependency Injection in C#?

Dependency Injection (DI) is a software design pattern where the objects are passed as dependencies instead of hard coding them within the class.

The concept of Dependency Injection comes, when you are trying to separate the logic of object creation and object consumption. The ‘config’ operation makes use of DI that must be configured beforehand while the module gets loaded to retrieve the elements of the application. With this feature, a user can change dependencies as per his requirements.