1. Explain the difference between a class and an
object.
In short, a class is
the definition of an object, and an object is instance of a class. We can look
at the class as a template of the object: it describes all the properties,
methods, states and behaviors that the implementing object will have. As
mentioned, an object is an instance of a class, and a class does not become an
object until it is instantiated. There can be more instances of objects based
on the one class, each with different properties.
2. Explain
the difference between managed and unmanaged code.
Managed
code is a code created by the .NET compiler. It does not depend on the
architecture of the target machine because it is executed by the CLR (Common
Language Runtime), and not by the operating system itself. CLR and managed code
offers developers few benefits, like garbage collection, type checking and
exceptions handling. On the other hand, unmanaged code is directly compiled to
native machine code and depends on the architecture of the target machine. It
is executed directly by the operating system. In the unmanaged code, the
developer has to make sure he is dealing with memory usage and allocation
(especially because of memory leaks), type safety and exceptions manually. In
.NET, Visual Basic and C# compiler creates managed code. To get unmanaged code,
the application has to be written in C or C++.
|
3. Explain the difference between boxing and unboxing.
Provide an example.
Boxing is the process
of converting a value type to the type object, and unboxing is extracting the
value type from the object. While the boxing is implicit, unboxing is explicit.
Example (written in C#):
~~~ int i = 13; object myObject = i; // boxing
i = (int)myObject; // unboxing ~~~
4. Explain what LINQ is.
LINQ is an acronym
for Language Integrated Query, and was introduced with Visual Studio 2008. LINQ
is a set of features that extends query capabilities to the .NET language
syntax by adding sets of new standard query operators that allow data
manipulation, regardless of the data source. Supported data sources are: .NET
Framework collections, SQL Server databases, ADO.NET Datasets, XML documents,
and any collection of objects that support `IEnumerable` or the generic
`IEnumerable` interface, in both C# and Visual Basic. In short, LINQ bridges
the gap between the world of objects and the world of data.
5. Explain the difference between the Stack and
the Heap.
The short answer would be: in the
Stack are stored value types (types inherited from `System.ValueType`), and in
the Heap are stored reference types (types inherited from `System.Object`). We
can say the Stack is responsible for keeping track of what is actually
executing and where each executing thread is (each thread has its own Stack).
The Heap, on the other hand, is responsible for keeping track of the data, or
more precise objects.
6. Explain the differences between an Interface and
an Abstract Class in .NET.
An **interface** merely declares
a contract or a behavior that implementing classes should have. It may declare
only properties, methods, and events with no access modifiers. All the declared
members must be implemented. An **abstract class** provides a partial
implementation for a functionality and some abstract/virtual members that must
be implemented by the inheriting entities. It can declare fields too. Neither
interfaces nor abstract classes can be instantiated.
7. What are the different validators in ASP.NET?
1.
Required
field Validator
2.
Range
Validator
3.
Compare
Validator
4.
Custom
Validator
5.
Regular
expression Validator
6.
Summary
Validator
8. From which base class all Web Forms are inherited?
Page
class.
9. What is ViewState?
ViewState
is used to retain the state of server-side objects between page post backs.
10. What are the different types of caching?
ASP.NET
has 3 kinds of caching :
1.
Output
Caching,
2.
Fragment
Caching,
3.
Data
Caching.
11. List the events in page life cycle.
1)
Page_PreInit
2) Page_Init
3) Page_InitComplete
4) Page_PreLoad
5) Page_Load
6) Page_LoadComplete
7) Page_PreRender
8) Render
2) Page_Init
3) Page_InitComplete
4) Page_PreLoad
5) Page_Load
6) Page_LoadComplete
7) Page_PreRender
8) Render
12. Write code to send e-mail from an ASP.NET application?
MailMessage mailMess =
new MailMessage ();
mailMess.From = "abc@gmail.com
";
mailMess.Subject =
"Test email";
mailMess.Body = "Hi
This is a test mail.";
SmtpMail.SmtpServer =
"localhost";
SmtpMail.Send (mailMess);
13.
What are Generics in C# ?
Generic
is a class which allows the user to define classes and methods with the
placeholder. Generics were added to version 2.0 of the C#
language.
The
basic idea behind using Generic is to allow type (Integer, String, … etc
and user-defined types) to be a parameter to methods, classes, and interfaces
Generics help to separate logic and data type to increase reusability.
In other words you can create a class whose data type can be defined on run
time.
14. What is type safe in
C#?
C# language is a type safe
language. ... NET helps write safe code. Type safety in . NET has
been introduced to prevent the objects of one type from peeking into the
memory assigned for the other object. Writing safe code also means to
prevent data loss during conversion of one type to another.
15. What is the
difference between custom and user control?
Custom Control
|
User Control
|
Derives from control
|
Derives from UserControl
|
Dynamic Layout
|
Static Layout
|
Defines a single control
|
Defines a set of con
|
It has full toolbox support
|
Cannot be added to the toolbox
|
Loosely coupled control
|
Tightly coupled control
|
16. Explain MVC.
MVC stands for model view controller
which is an architecture to build .NET applications.
Model: They are the logical
part of any application that handles the object storage and retrieval from the
databases for an application.
View: View handles the UI
part of an application. They get the information from the models for their
display.
Controller: They handle the user
interactions, figure out the responses for the user input and also render the
view that is required for the user interaction.
17. What is the
difference between overloading and overriding?
Overloading occurs when two or
more methods in one class have the same method name but different
parameters.
Overriding allows a child class to
provide a specific implementation of a method that is already provided its
parent class
18. Why method overriding
is used?
In object-oriented programming, the feature of overriding
is used to provide a class, subclass or a child class to use a method
that is already used by parent class to have a specific implementation.
19. What is polymorphism
and example?
The word polymorphism
means having many forms.
Real life example
of polymorphism: A person at the same time can have different
characteristic. Like a man at the same time is a father, a husband, an
employee. So the same person possess different behavior in different
situations. This is called polymorphism.
20. What is OOPs concept
with example?
Object-Oriented
Programming
is a paradigm that provides many concepts, such as inheritance, data
binding, polymorphism, etc.
The main aim of object-oriented
programming is to implement real-world entities,
for example, object, classes,
abstraction, inheritance, polymorphism, etc.
thanks for sharing good interview questions…
ReplyDeleteThanks Vivek
DeleteNice interview questions. Its very helpful for bignners as well as 1-2 year experience holder
ReplyDeleteThank you :)
DeleteShort and straight.Thanks for sharing.
ReplyDeleteThank you:)
Delete