Oops Interview
Oops Interview
Encapsulation-
Encapsulation is the concept of wrapping data into a single unit. It collects data
members and member functions into a single unit called class.
By using the encapsulation program, we can hide the members of one class from
another class.
Abstraction-
It is one of the major principle of oops.
It allows the programmer to display only the necessary data while hiding the others
from the user.
Polymorphism
Polymorphism means one name, many forms. One function behaves in different forms.
In other words, "Many forms of a single object is called Polymorphism."
Method Overloading
Method Overloading is a type of polymorphism. It has several names like “Compile
Time Polymorphism” or “Static Polymorphism,” and sometimes it is called “Early
Binding”.
Method Overloading means creating multiple methods in a class with the same names
but different Parameters.
Method Overriding is a type of polymorphism. It has several names like “Run Time
Polymorphism” or “Dynamic Polymorphism,” and sometimes it is called “Late Binding”.
Method Overriding means having two methods with the same name and same
[parameters]; one should be in the base class, and another method should be in a
derived class [child class]
Inheritance.
Inheritance, in C#, is the ability to create a class that inherits attributes and
behaviors from an existing class. The newly created class is the derived (or child)
class and the existing class is the base (or parent) class. Inheritance is one of
the key features of object-oriented programming.
Abstract class: is a restricted class that cannot be used to create objects .To
access it, it must be inherited from another class.
Abstract method: it can only be used in an abstract class, and it does not have a
body. The body is provided by the derived class (inherited from).
Constructors
A constructor is a special method that is used to initialize objects. The advantage
of a constructor, is that it is called when an object of a class is created. It can
be used to set initial values for fields.
protected -The code is accessible within the same class, or in a class that is
inherited from that class.
internal- The code is only accessible within its own assembly, but not from another
assembly.
Stringbuilder
StringBuilder is mutable, means if create string builder object then you can
perform any operation like insert, replace or append without creating new instance
for every time.it will update string at one place in memory doesnt create new space
in memory.
Session:
Think of a session as a temporary storage area that is unique to each user during
their visit to a website.
When a user visits a website, a session is created for that user. It can store
information that is specific to that user's interaction with the site.
The session data is stored on the web server, not on the user's computer.
It is typically used for storing things like user login information, shopping cart
contents, and other user-specific data.
Cookie: