0% found this document useful (0 votes)
17 views6 pages

Liner Interview

Uploaded by

Rupesh Rai
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)
17 views6 pages

Liner Interview

Uploaded by

Rupesh Rai
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
You are on page 1/ 6

OOP Features

 Object Oriented Programming (OOP) is a programming model where programs are


organized around objects and data rather than action and logic.

Class
 A class is a blueprint of an object that contains variables for storing data and functions
to perform operations on the data.

Object

 Objects are the basic run-time entities of an object-oriented system. They may
represent a person, a place or any item that the program must handle.

"An object is a software bundle of related variable and methods."

"An object is an instance of a class"

Abstraction

 Abstraction is the process of hiding the working style of an object and showing the
information of an object in an understandable manner.

Abstraction is "To represent the essential feature without representing the background
details."

Encapsulation
 Encapsulation means hiding the internal details of an object, in other words how an
object does something.
 Wrapping up a data member and a method together into a single unit (in other words
class) is called Encapsulation.

https://www.tutlane.com/tutorial/csharp/csharp-encapsulation

Inheritance
 Inheritance is a process of object reusability.

Polymorphism
 Polymorphism provides the ability to a class to have multiple
implementations with the same name.

Static or Compile Time Polymorphism


 Method overloading is an example of Static Polymorphism. In overloading, the
method / function has a same name but different signatures.

Dynamic / Runtime Polymorphism


 Dynamic / runtime polymorphism is also known as late binding. Here, the
method name and the method signature (number of parameters and
parameter type must be the same and may have a different
implementation). Method overriding is an example of dynamic polymorphism.

Differences between Abstraction and Encapsulation

Abstraction Encapsulation

1. Abstraction solves the problem at the 1. Encapsulation solves the problem in the
design level. implementation level.

2. Abstraction hides unwanted data and 2. Encapsulation means hiding the code and data into a
provides relevant data. single unit to protect the data from the outside world.

3. Abstraction lets you focus on what the 3. Encapsulation means hiding the internal details or
object does instead of how it does it mechanics of how an object does something.

4. Abstraction: Outer layout, used in terms of


4. Encapsulation- Inner layout, used in terms of
design.
implementation.
For example:
An external of a Mobile Phone, like it has a For example: the internal details of a Mobile Phone,
display screen and keypad buttons to dial a how the keypad button and display screen relate to
number. each other using circuits.
What Is an Interface?
An interface is a contract between itself and any class that implements it. This contract states
that any class that implements the interface will implement the interface's properties,
methods and/or events. An interface contains no implementation, only the signatures of the
functionality the interface provides. An interface can contain signatures of methods, properties,
indexers, and events.

Why Use Interfaces?


Using interface-based design concepts provides loose coupling, component-based programming,
easier maintainability, makes your code base more scalable and makes code reuse much more
accessible because the implementation is separated from the interface. Interfaces add a plug and
play like architecture into your applications. Interfaces help define a contract (agreement or
blueprint, however you chose to define it), between your application and other objects. This
indicates what sort of methods, properties, and events are exposed by an object.

Generics
Generics allow you to define type-safe classes without compromising type safety, performance
or productivity. Generic introduce to the .NET Framework the concept of type parameter, which
make it possible to design classes and methods.

Delegates have the following properties:


1. Delegates are like C++ function pointers but are type safe.
2. Delegates allow methods to be passed as parameters.
3. Delegates can be used to define callback methods.
4. Delegates can be chained together; for example, multiple methods can be called on a
single event.
5. Methods don't need to match the delegate signature exactly.
6. Using a delegate allows the programmer to encapsulate a reference to a method inside a
delegate object. The delegate object can then be passed to code that can call the
referenced method, without having to know at compile time which method will be
invoked.
7. An interesting and useful property of a delegate is that it does not know or care about the
class of the object that it references. Any object will do; all that matters is that the
method's argument types and return type match the delegates. This makes delegates
perfectly suited for "anonymous" invocation.

Namespace
In c#, Namespace is used to organize the multiple classes in our applications and it will reduce the
code redundancy in our .NET applications. By using the namespace keyword, we can define the
namespaces in our c# applications.

1. What is solid principle?


SOLID refers to a set of principles of oop and design. These principles are intended for developers to
write maintainable, extensible code. These principles are as follows

S- Single Responsibility Principle

O- Open/Closed Principle

L- Liskov Substitution Principle

I – Interface Segregation Principle

D – Dependency Inversion Principle

Benefit of solid

Encourages good design

Drives consistency in design

Increases cohesion in classes

Reduces coupling between classes

Simplifies debugging

Simplifies maintenance

Simplifies unit testing

1. Single responsibility principle (SRP)

A class should take one responsibility and there should be one reason to change that class.

2. Open closed principle (OCP)

This class should be open for extension but closed for modification. But how to do that!!

3. Liskov substitution principle (LSP)

Child class should not break parent class’s type definition and behavior.
4. Interface segregation principle (ISP)
This principle states that any client should not be forced to use an interface which is
irrelevant to it.
5. Dependency inversion principle (DIP)
This principle tells you not to write any tightly coupled code because that is a
nightmare to maintain when the application is growing bigger and bigger. If a class
depends on another class, then we need to change one class if something changes in
that dependent class. We should always try to write loosely coupled class.

Example: Notification Engine (Email,Sms,HardCopy)

Design Patterns In C#
Design patterns provide general solutions or a flexible way to solve common design
problems.

Singleton Design Pattern

This pattern ensures that the class has only one instance and provides a global point
of access to it. The pattern ensures that only one object of a specific class is ever
created.

Ref
The ref keyword is used to pass an argument as a reference. This means that when value
of that parameter is changed in the method, it gets reflected in the calling method. An
argument that is passed using a ref keyword must be initialized in the calling method
before it is passed to the called method.

Out
The out keyword is also used to pass an argument like ref keyword, but the argument
can be passed without assigning any value to it. An argument that is passed using an
out keyword must be initialized in the called method before it returns back to calling
method.
1. What is Multithreading in C#?
Multithreading allows you to perform concurrent processing so that you can do more
than one operation at a time. The .NET Framework System. Threading namespace is
used to perform threading in C#.

2. What are Generics in C#?


Generics allow you to define type-safe classes, interfaces, methods, events, delegates,
and generic collections without compromising type safety, performance, or productivity.
In generics, a generic type parameter is supplied between the open (<) and close (>)
brackets and which makes it strongly typed collections i.e. generics collections contain
only similar types of objects.

3. What is finalize () method?


Finalize method is used to free unmanaged resources like files, database connections,
COM, etc. held by an object before that object is destroyed. Internally, it is called by
Garbage Collector and cannot be called by user code.

1. What is Constructor?
A constructor is a special type of function/method which has the same name as its class.
The constructor is invoked whenever an object of a class is created. It is called
constructor since it constructs the values of the class data members.

You might also like