http://csharppulse.blogspot.in/2013/08/c-and-aspnet-interview-question-and.html
http://www.indiabix.com/technical/dotnet/asp-dot-net/1
http://www.dotnetspider.com/resources/43107-How-write-connection-string-place.aspx
http://www.iminfo.in/post/advanced-c-sharp-dot-net-interview-questions-for-experienced--developers
http://www.careerride.com/ASPNet-Questions.aspx
http://www.aspdotnet-suresh.com/2010/05/interview-questions-in-aspnetcnetsql.html
http://www.dotnetfunda.com/interviews/cat/5/aspnet
Describe the complete lifecycle of a Web page.
When we execute a Web page, it passes from the following stages, which are collectively known as Web page lifecycle:
Page request - During this stage, ASP.NET makes sure the page either parsed or compiled and a cached version of the page can be sent in response
Start - During this stage sets the Request and Response page properties and the page check the page request is either a postback or a new request
Page Initialization - During this stage, the page initialize and the control's Unique Id property are set
Load - During this stage, if the request is postback, the control properties are loaded without loading the view state and control state otherwise loads the view state
Validation - During this stage, the controls are validated
Postback event handling - During this stage, if the request is a postback, handles the event
Rendering - During this stage, the page invokes the Render method to each control for return the output
Unload - During this stage, when the page is completely rendered and sent to the client, the page is unloaded.
How can you enable impersonation in the web.config file?
To enable impersonation in the web.confing file, you need to include the <identity> element in theweb.config file and set the impersonate attribute to true as shown in the following code snippet:
<identity impersonate = "true" />
How can you ensure that no one has tampered with ViewState in a Web page?
To ensure that no one has tampered with ViewState in a Web page, set the EnableViewStateMac property to True.
What are the major built-in objects in ASP.NET?
The major built-in objects in ASP.NET are as follows:
Application
Request
Response
Server
Session
Context
Trace
Which data type does the RangeValidator control support?
The data types supported by the RangeValidator control are Integer, Double, String, Currency, and Date.
Explain the validation controls. How many validation controls in ASP.NET 4.0?
Validation controls are responsible to validate the data of an input control. Whenever you provide any input to an application, it performs the validation and displays an error message to user, in case the validation fails.
ASP.NET 4.0 contains the following six types of validation controls:
Explain the validation controls. How many validation controls in ASP.NET 4.0?
Validation controls are responsible to validate the data of an input control. Whenever you provide any input to an application, it performs the validation and displays an error message to user, in case the validation fails.
ASP.NET 4.0 contains the following six types of validation controls:
CompareValidator - Performs a comparison between the values contained in two controls.
CustomValidator - Writes your own method to perform extra validation.
RangeValidator- Checks value according to the range of value.
RegularExpressionValidator - Ensures that input is according to the specified pattern or not.
RequiredFieldValidator - Checks either a control is empty or not.
ValidationSummary - Displays a summary of all validation error in a central location.
How many types of Cookies are available in ASP.NET?
There are two types of Cookies available in ASP.NET:
Session Cookie - Resides on the client machine for a single session until the user does not log out.
Persistent Cookie - Resides on a user's machine for a period specified for its expiry, such as 10 days, one month, and never.
The user can set this period manually.
What events are fired when a page loads?
The following events fire when a page loads:
Init() - Fires when the page is initializing.
LoadViewState() - Fires when the view state is loading.
LoadPostData() - Fires when the postback data is processing.
Load() - Fires when the page is loading.
PreRender() - Fires at the brief moment before the page is displayed to the user as HTML.
Unload() - Fires when the page is destroying the instances of server controls.
What is the difference between a HyperLink control and a LinkButton control?
A HyperLink control does not have the Click and Command events; whereas, the LinkButton control has these events, which can be handled in the code-behind file of the Web page.
What are the different Session state management options available in ASP.NET?
In-Process
Out-of-Process.
In-Process stores the session in memory on the web server.
Out-of-Process Session state management stores data in an external server. The external server may be either a SQL Server or a State Server. All objects stored in session are required to be serializable for Out-of-Process state management.
What are the advantages of Passport authentication?
All the websites can be accessed using single login credentials. So no need to remember login credentials for each web site.
Users can maintain his/ her information in a single location
What are differences between Array list and Hash table?
Ans: 1) Hash table store data as name, value pair. While in array only value is store.
2) To access value from hash table, you need to pass name. While in array, to access value, you need to pass index number.
3) you can store different type of data in hash table, say int, string etc. while in array you can store only similar type of data.
What are difference between GET and POST Methods?
Ans:
GET Method ():
1) Data is appended to the URL.
2) Data is not secret.
3) It is a single call system
4) Maximum data that can be sent is 256.
5) Data transmission is faster
6) this is the default method for many browsers
POST Method ():
1) Data is not appended to the URL.
2) Data is Secret
3) it is a two call system.
4) There is no Limit on the amount of data. That is characters any amount of data can be sent.
5) Data transmission is comparatively slow.
6) No default and should be explicitly specified.
What are difference between truncate and delete?
Ans:
CustomValidator - Writes your own method to perform extra validation.
RangeValidator- Checks value according to the range of value.
RegularExpressionValidator - Ensures that input is according to the specified pattern or not.
RequiredFieldValidator - Checks either a control is empty or not.
ValidationSummary - Displays a summary of all validation error in a central location.
How many types of Cookies are available in ASP.NET?
There are two types of Cookies available in ASP.NET:
Session Cookie - Resides on the client machine for a single session until the user does not log out.
Persistent Cookie - Resides on a user's machine for a period specified for its expiry, such as 10 days, one month, and never.
The user can set this period manually.
What events are fired when a page loads?
The following events fire when a page loads:
Init() - Fires when the page is initializing.
LoadViewState() - Fires when the view state is loading.
LoadPostData() - Fires when the postback data is processing.
Load() - Fires when the page is loading.
PreRender() - Fires at the brief moment before the page is displayed to the user as HTML.
Unload() - Fires when the page is destroying the instances of server controls.
What is the difference between a HyperLink control and a LinkButton control?
A HyperLink control does not have the Click and Command events; whereas, the LinkButton control has these events, which can be handled in the code-behind file of the Web page.
What are the different Session state management options available in ASP.NET?
In-Process
Out-of-Process.
In-Process stores the session in memory on the web server.
Out-of-Process Session state management stores data in an external server. The external server may be either a SQL Server or a State Server. All objects stored in session are required to be serializable for Out-of-Process state management.
What are the advantages of Passport authentication?
All the websites can be accessed using single login credentials. So no need to remember login credentials for each web site.
Users can maintain his/ her information in a single location
What are differences between Array list and Hash table?
Ans: 1) Hash table store data as name, value pair. While in array only value is store.
2) To access value from hash table, you need to pass name. While in array, to access value, you need to pass index number.
3) you can store different type of data in hash table, say int, string etc. while in array you can store only similar type of data.
What are difference between GET and POST Methods?
Ans:
GET Method ():
1) Data is appended to the URL.
2) Data is not secret.
3) It is a single call system
4) Maximum data that can be sent is 256.
5) Data transmission is faster
6) this is the default method for many browsers
POST Method ():
1) Data is not appended to the URL.
2) Data is Secret
3) it is a two call system.
4) There is no Limit on the amount of data. That is characters any amount of data can be sent.
5) Data transmission is comparatively slow.
6) No default and should be explicitly specified.
What are difference between truncate and delete?
Ans:
1) Delete keep the lock over each row where Truncate keeps the lock on table not on all the row.
2) Counter of the Identity column is reset in Truncate where it is not reset in Delete.
3) Trigger is not fired in Truncate where as trigger is fired in Delete.
4) In TRUNCATE we cannot rollback.
5) In DELETE we can rollback
What is a Partial class?
Ans:
3) Trigger is not fired in Truncate where as trigger is fired in Delete.
4) In TRUNCATE we cannot rollback.
5) In DELETE we can rollback
What is a Partial class?
Ans:
Instead of defining an entire class, you can split the definition into multiple classes by using partial class keyword. When the application compiled, c# compiler will group all the partial classes together and treat them as a single class. There are a couple of good reasons to use partial classes. Programmers can work on different parts of classes without needing to share same physical file
Ex:
Public partial class employee
{
Public void somefunction()
{
}
}
Public partial class employee
{
Public void function ()
{
}
}
What is the serialization?
Ans:
Ex:
Public partial class employee
{
Public void somefunction()
{
}
}
Public partial class employee
{
Public void function ()
{
}
}
What is the serialization?
Ans:
Serialization is a process of converting object into a stream of bites.
Design Pattern Training / Interview Questions and Answers
Factory Design Pattern
Abstract Factory Design Pattern
Builder Design Pattern
Prototype Design Pattern
Singleton Design Pattern
Adapter Design Pattern
Bridge Design Pattern
Composite Design Pattern
Decorator Design Pattern
Facade Design Pattern
Flyweight Design Pattern
Proxy Design Pattern
Mediator Design Pattern
Memento Design Pattern
Interpreter Design Pattern
Iterator Design Pattern
COR Design Pattern
Command Design Pattren
State Design Pattern
Strategy Design Pattern
Observer Design Pattern
Template Design Pattern
Visitor Design Pattern
Dependency IOC Design pattern
Design Pattern Training / Interview Questions and Answers
Factory Design Pattern
Abstract Factory Design Pattern
Builder Design Pattern
Prototype Design Pattern
Singleton Design Pattern
Adapter Design Pattern
Bridge Design Pattern
Composite Design Pattern
Decorator Design Pattern
Facade Design Pattern
Flyweight Design Pattern
Proxy Design Pattern
Mediator Design Pattern
Memento Design Pattern
Interpreter Design Pattern
Iterator Design Pattern
COR Design Pattern
Command Design Pattren
State Design Pattern
Strategy Design Pattern
Observer Design Pattern
Template Design Pattern
Visitor Design Pattern
Dependency IOC Design pattern
5. Difference between Functions and methods.
A. in.Net terminology, both are same. in general, we use method in .net but in scripting language we use function like JavaScript function.
Here the difference can be Function always returns a value which method may or may not. It depends upon the return type of the method.
Q14. What is single sign on? Can you tell us web sites who uses this feature.
Ans. e.g. Once you login to google you don;t need to login to again for gmail, orkut, feedburner or any other google product.
What are the types of comment in C#?
Does c# support multiple inheritance? No
A. in.Net terminology, both are same. in general, we use method in .net but in scripting language we use function like JavaScript function.
Here the difference can be Function always returns a value which method may or may not. It depends upon the return type of the method.
Q14. What is single sign on? Can you tell us web sites who uses this feature.
Ans. e.g. Once you login to google you don;t need to login to again for gmail, orkut, feedburner or any other google product.
What are the types of comment in C#?
There are 3 types of
comments in C#.
Single line (//)
Multi (/* */)
Page/XML Comments
(///).
1. What are the namespaces used in C#.NET?
Namespace is a logical
grouping of class.
using System;
using
System.Collections.Generic;
using System.Windows.Forms;
1. What are the characteristics of C#?
There are several
characteristics of C# are :
- Simple
- Type safe
- Flexible
- Object oriented
- Compatible
- Consistent
- Interoperable
- Modern
1. What are the different categories of inheritance?
Inheritance in Object
Oriented Programming is of four types:
Single inheritance: Contains one base class and one derived class.
Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.
Multilevel inheritance: Contains a class derived from a derived class.
Multiple inheritance: Contains several base classes and a derived class.
Single inheritance: Contains one base class and one derived class.
Hierarchical inheritance: Contains one base class and multiple derived classes of the same base class.
Multilevel inheritance: Contains a class derived from a derived class.
Multiple inheritance: Contains several base classes and a derived class.
1. What are the basic concepts of object oriented programming?
It is necessary to
understand some of the concepts used extensively in object oriented
programming.These include:
Objects
Classes
Data abstraction and
encapsulation
Inheritance
Polymorphism
Dynamic Binding
Message passing.
1. Can you inherit multiple interfaces?
Yes. Multiple
interfaces may be inherited in C#.
1. What is inheritance?
Inheritance is
deriving the new class from the already existing one.
1. Define scope?
Scope refers to the
region of code in which a variable may be accessed.
1. What is the difference between public, static and void?
public: The keyword public is an access modifier that tells the C#
compiler that the Main method is accessible by anyone.
static: The
keyword static declares that the Main method is a global one and can be called
without creating an instance of the class. The compiler stores the address
of the method as the entry point and uses this information to begin execution
before any objects are created.
void: The keyword void is a type modifier that states that the Main
method does not return any value.
1. What are the modifiers in C#?
Abstract
Sealed
Virtual
Const
Event
Extern
Override
Readonly
Static
New
1. What are the types of access modifiers in C#?
public
protect
private
internal
internal protect
1. What is boxing and unboxing?
Implicit conversion of
value type to reference type of a variable is known as BOXING, for example
integer to object type conversion.
Conversion of
reference type variable back to value type is called as UnBoxing.
1. What is object?
An object is an
instance of a class. An object is created by using operator new. A class that
creates an object in memory will contain the information about the values
and behaviors (or methods) of that specific object.
1. Where are the types of arrays in C#?
Single-Dimensional
Multidimensional
Jagged arrays.
1. What is the difference between Object and Instance?
An instance of a
user-defined type is called an object. We can instantiate many objects from one
class.
An object is an instance
of a class.
1. Define destructors?
A destructor is called
for a class object when that object passes out of scope or is explicitly
deleted.A destructors as the name implies is used to destroy the objects
that have been created by a constructors.Like a constructor , the destructor is
a member function whose name is the same as the class name but
is precised by a tilde.
1. What is the use of enumerated data type?
An enumerated data
type is another user defined type which provides a way for attaching names to
numbers thereby increasing comprehensibility of the code. The enum keyword
automatically enumerates a list of words by assigning them values 0,1,2, and so
on.
1. Define Constructors?
A constructor is a
member function with the same name as its class. The constructor is invoked
whenever an object of its associated class is created.It is called
constructor because it constructs the values of data members of the class.
1. What is encapsulation?
The wrapping up of
data and functions into a single unit (called class) is known as encapsulation.
Encapsulation containing and hiding information about an object, such as
internal data structures and code.
Does c# support multiple inheritance? No
1. What is ENUM?
Enum are used to
define constants.
1. What is a data set?
A DataSet is an in
memory representation of data loaded from any data source.
1. What is the difference between private and public keyword?
Private: The private keyword is the default access level and most
restrictive among all other access levels. It gives least permission to a
type or type member. A private member is accessible only within the body of the
class in which it is declared.
Public: The
public keyword is most liberal among all access levels, with no restrictions to
access what so ever. A public member is accessible not only from within,
but also from outside, and gives free access to any member declared within the
body or outside the body.
1. Define polymorphism?
Polymorphism means one
name, multiple forms. It allows us to have more than one function with the same
name in a program. It allows us to have overloading of operators so that
an operation can exhibit different behaviors in different instances.
1. What is Jagged Arrays?
A jagged array is an
array whose elements are arrays.
The elements of a
jagged array can be of different dimensions and sizes.
A jagged array is
sometimes called an array–of–arrays.
1. What is an abstract base class?
An abstract class is a
class that is designed to be specifically used as a base class. An abstract
class contains at least one pure virtual function.
1. How is method overriding different from method overloading?
When overriding a
method, you change the behavior of the method for the derived class.
Overloading a method simply involves having another method with the same
name within the class.
1. What is the difference between ref & out parameters?
An argument passed to
a ref parameter must first be initialized. Compare this to an out parameter,
whose argument does not have to be explicitly initialized before being
passed to an out parameter.
1. What is the use of using statement in C#?
The using statement is
used to obtain a resource, execute a statement, and then dispose of that
resource.
31.What
is serialization?
Serialization is
the process of converting an object into a stream of bytes.
De-serialization is the opposite process of creating an object from a stream
of bytes.
Serialization /
De-serialization is mostly used to transport objects.
1. What are the difference between Structure and Class?
Structures are value
type and Classes are reference type
Structures can not have
contractors or destructors.
Classes can have both
contractors and destructors.
Structures do not
support Inheritance, while Classes support Inheritance.
1. What is difference between Class And Interface?
Class is
logical representation of object. It is collection of data and related sub
procedures with defination.
Interface is
also a class containg methods which is not having any definations.Class does
not support multiple inheritance. But interface can support.
1. What is Delegates?
Delegates are a
type-safe, object-oriented implementation of function pointers and are used in
many situations where a component needs to call back to the component that
is using it.
1. What is Authentication and Authorization?
Authentication is the
process of identifying users. Authentication is identifying/validating the user
against the credentials (username and password).
Authorization performs
after authentication. Authorization is the process of granting access to those
users based on identity.
Authorization allowing
access of specific resource to user.
1. What is a base class?
A class declaration
may specify a base class by following the class name with a colon and the name
of the base class. omitting a base class specification is the same as
deriving from type object.
1. Can “this” be used within a static method?
No ‘This’ cannot be
used in a static method. As only static variables/methods can be used in a
static method.
1. What is difference between constants, readonly and, static ?
Constants:
The value can’t be changed.
Read-only:
The value will be initialized only once from the constructor of the class.
Static:
Value can be initialized once.
1. What are the different types of statements supported in C#?
Block statements
Declaration statements
Expression statements
Selection statements
Iteration statements
Jump statements
Try catch statements
Checked and unchecked
Lock statement
1. What is an interface class?
It is an abstract
class with public abstract methods all of which must be implemented in the
inherited classes.
41.What
are value types and reference types?
Value types are stored
in the Stack.
Examples : bool, byte,
chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint,
ulong, ushort.
Reference types are
stored in the Heap.
Examples : class,
delegate, interface, object, string.
1. What is the difference between string keyword and
System.String class?
String keyword is an
alias for System.String class.
Therefore, System.String and string keyword are the same, and you can use whichever naming convention you prefer.
The String class provides many methods for safely creating, manipulating, and comparing strings.
Therefore, System.String and string keyword are the same, and you can use whichever naming convention you prefer.
The String class provides many methods for safely creating, manipulating, and comparing strings.
1. What are the two data types available in C#?
Value type
Reference type
1. What are the different types of Caching?
There are three types
of Caching:
Output
Caching: stores the responses from an asp.net page.
Fragment
Caching: Only caches/stores the portion of page (User Control)
Data
Caching: is Programmatic way to Cache objects for performance.
1. What is the difference between Custom Control and User
Control?
Custom Controls are
compiled code (Dlls), easier to use, difficult to create, and can be placed in
toolbox. Drag and Drop controls.
Attributes can be set
visually at design time. Can be used by Multiple Applications (If Shared Dlls),
Even if Private can copy to bin directory of web application add reference
and use. Normally designed to provide common functionality independent of
consuming Application.
User Controls are
similar to those of ASP include files, easy to create, can not be placed in the
toolbox and dragged - dropped from it. A User Control is shared among the
single application files.
1. What is methods?
A method is a member
that implements a computation or action that can be performed by an object or
class. Static methods are accessed through the class. Instance methods are
accessed through instances of the class.
1. What is fields?
A field is a variable
that is associated with a class or with an instance of a class.
1. What is events?
An event is a member
that enables a class or object to provide notifications. An event is declared
like a field except that the declaration includes an event keyword and the
type must be a delegate type.
1. What is literals and their types?
Literals are value
constants assigned to variables in a program. C# supports several types of
literals are
Integer literals
Real literals
Boolean literals
Single character
literals
String literals
Backslash character
literals
1. What is the difference between value type and reference type?
Value types are stored
on the stack and when a value of a variable is assigned to another variable.
Reference types are
stored on the heap, and when an assignment between two reference variables
occurs.
1. What are the features of c#?
C# is a simple and
powerful programming language for writing enterprise edition applications.
This is a hybrid of
C++ and VB. It retains many C++ features in the area statements,expressions,
and operators and incorporated the productivity of VB.
C# helps the
developers to easily build the web services that can be used across the
Internet through any language, on any platform.
C# helps the
developers accomplishing with fewer lines of code that will lead to the fewer
errors in the code.
C# introduces the
considerable improvement and innovations in areas such as type
safety,versioning. events and garbage collections.
1. What are the types of errors?
Syntax error
Logic error
Runtime error
1. What is the difference between break and continue statement?
The break statement is
used to terminate the current enclosing loop or conditional statements in which
it appears. We have already used the break statement to come out of switch
statements.
The continue statement
is used to alter the sequence of execution. Instead of coming out of the loop
like the break statement did, the continue statement stops the current
iteration and simply returns control back to the top of the loop.
1. Define namespace?
The namespace are
known as containers which will be used to organize the hierarchical set of .Net
classes.
1. What is a code group?
A code group is a set
of assemblies that share a security context.
1. What are sealed classes in C#?
The sealed modifier is
used to prevent derivation from a class. A compile-time error occurs if a
sealed class is specified as the base class of another class.
1. What is the difference between static and instance methods?
A method declared with
a static modifier is a static method. A static method does not operate on a
specific instance and can only access static members.
A method declared
without a static modifier is an instance method. An instance method operates on
a specific instance and can access both static and instance members. The
instance on which an instance method was invoked can be explicitly accessed as
this. It is an error to refer to this in a static method.
1. What are the different types of variables in C#?
static variables
instance variable
value parameters
reference parameters
array elements
output parameters
local variables
1. What is meant by method overloading?
Method overloading
permits multiple methods in the same class to have the same name as long as
they have unique signatures. When compiling an invocation of an overloaded
method, the compiler uses overload resolution to determine the specific method
to invoke.
1. What is parameters?
Parameters are used to
pass values or variable references to methods. The parameters of a method get
their actual values from the arguments that are specified when the method
is invoked. There are four kinds of parameters: value parameters, reference parameters,
output parameters, and parameter arrays.
1. Is C# is object oriented?
Yes, C# is an OO
langauge in the tradition of Java and C++.
1. What is the difference between Array and Arraylist?
An array is a
collection of the same type. The size of the array is fixed in its declaration.
A linked list is similar to an array but it doesn’t have a limited size.
1. What are the special operators in C#?
is (relational
operator)
as (relational
operator)
typeof (type
operator)
sizeof (size
operator)
new (object creator)
.dot (member access
operator)
checked (overflow
checking)
unchecked (prevention
of overflow checking)
1. What is meant by operators in c#?
An operator is a
member that defines the meaning of applying a particular expression operator to
instances of a class. Three kinds of operators can be defined: unary
operators, binary operators, and conversion operators. All operators must be
declared as public and static.
1. What is a parameterized type?
A parameterized type
is a type that is parameterized over another value or type.
1. What are the features of abstract class?
An abstract class
cannot be instantiated, and it is an error to use the new operator on an
abstract class.
An abstract class is
permitted (but not required) to contain abstract methods and accessors.
An abstract class
cannot be scaled.
1. What is the use of abstract keyword?
The modifier abstract
is a keyword used with a class, to indicate that this class cannot itself have
direct instances or objects, and it is intended to be only a 'base' class
to other classes.
1. What is the use of goto statement?
The goto statement is
also included in the C# language. This goto can be used to jump from inside a
loop to outside. But jumping from outside to inside a loop is not allowed.
1. What is the difference between console and window
application?
A console application,
which is designed to run at the command line with no user interface.
A Windows application,
which is designed to run on a user’s desktop and has a user interface.
1. What is the use of return statement?
The return statement
is associated with procedures (methods or functions). On executing the return
statement, the system passes the control from the called procedure to the
calling procedure. This return statement is used for two purposes :
to return immediately
to the caller of the currently executed code
to return some value
to the caller of the currently executed code.
1. What is the difference between Array and LinkedList?
Array is a simple
sequence of numbers which are not concerned about each others positions. they
are independent of each others positions. adding,removing or modifying any
array element is very easy. Compared to arrays ,linked list is a comlicated sequence
of numbers.
1. Does C# have a throws clause?
No, unlike Java, C#
does not require the developer to specify the exceptions that a method can
throw.
1. Does C# support a variable number of arguments?
Yes, uisng the params
keyword. The arguments are specified as a list of arguments of a specific type.
1. Can you override private virtual methods?
No, private methods
are not accessible outside the class.
1. What is a multi cast delegates?
Each delegate object
holds reference to a single method. However, it is possible for a delegate
object to hold references of and invoke multiple methods. Such delegate
objects are called multicast delegates or combinable delegates.
1. Which is an exclusive feature of C#?
Xml documentation.
1. Is using of exceptions in C# recommended?
Yes, exceptions are
the recommended error handling mechanism in .NET Framework.
1. What does a break statement do in switch statements?
The break statement
terminates the loop in which it exists. It also changes the flow of the
execution of a program.
In switch statements,
the break statement is used at the end of a case statement. The break statement
is mandatory in C# and it avoids the fall through of one case statement to
another.
1. Is C# object oriented?
Yes, C# is an OO
language in the tradition of java and C++.
1. What is smart navigation?
The cursor position is
maintained when the page gets refreshed due to the server side validation and
the page gets refreshed.
1. What is the difference between CONST and READONLY?
Both are meant for
constant values. A const field can only be initialized at the declaration of
the field. A readonly field can be initialized either at the declaration
or.
1. Does C# have a throws clause?
No, unlike Java, C#
does not require (or even allow) the developer to specify the exceptions that a
method can throw.
1. What are the different ways a method can be overloaded?
Different parameter
data types, different number of parameters, different order of parameters.
1. Do events have return type?
No, events do not have
return type.
1. What is event?
An event is an action
performed based on another method of the program.
An event is a delegate
type dass member that is used by an object or a class to provide a notification
to other objects that an event has occurred.
An event can be
declared with the help of the event keyword.
1. What is an identifier?
Identifiers are nothing
but names given to various entities uniquely identified in a program.
1. What are the different types of literals in C#?
Boolean
literals: True and False are literals of the Boolean type that map to
the true and false state, respectively.
Integer
literals: Used to write values of types Int, ulnt, long, and ulong.
Real
literals: Used to write values of types float, double, and dedmal.
Character
literals: Represents a single character and usually consists of a
character in quotes, such as 'a'.
String
literals: C# supports two types of string literals, regular string
literal and verbatim string literals. A regular string literal consists
of zero or more characters enclosed in double quotes, such as
"116110". A verbatim string literal consists of an @ character
followed by a double–quote character, such as ©"hello".
The
Null literal: Represents the null–type.
1. What is meant by data encapsulation?
Data encapsulation,
also referred to as data hiding, is the mechanism whereby the implementation details
of a class are kept hidden from the user. The user can only perform a
restricted set of operations on the hidden members of the class by executing
special functions called methods.
1. Can you override private virtual methods?
No. Private methods are
not accessible outside the class.
1. What is the main difference between a subprocedure and a
function?
Subprocedures do not
return a value, while functions do.
1. How does C# differ from C++?
C# does not support
#include statement. It uses only using statement.
In C# , class
definition does not use a semicolon at the end.
C# does not support
multiple code inheritance.
Casting in C# is much
safer than in c++.
In C# switch can also
be used on string values.
Command line
parameters array behave differently in C# as compared to C++.
1. What is nested class?
A nested class is any
class whose declaration occurs within the body of another class or interface.
1. Can you have parameters for static constructors?
No, static
constructors cannot have parameters.
1. Is String is Value Type or Reference Type in C#?
String is an
object(Reference Type).
1. Does C# provide copy constructor?
No, C# does not
provide copy constructor.
1. Can a class or a struct have multiple constructors?
Yes, a class or a
struct can have multiple constructors. Constructors in C# can be overloaded.
1. Can you create an instance of an interface?
No, you cannot create
an instance of an interface.
1. Can an Interface contain fields?
No, an Interface
cannot contain fields.
1. Can a class have static constructor?
Yes, a class can have
static constructor. Static constructors are called automatically, immediately
before any static fields are accessed, and are generally used to
initialize static class members. It is called automatically before the first
instance is created or any static members are referenced. Static
constructors are called before instance constructors. An example is shown
below.
1. What is the main use of delegates in C#?
Delegates are mainly
used to define call back methods.
1. What is the difference between Shadowing and Overriding?
Overriding redefines
only the implementation while shadowing redefines the whole element.
In overriding derived
classes can refer the parent class element by using "ME" keyword, but
in shadowing you can access it by "MYBASE".
1. Can events have access modifiers?
Yes, you can have
access modifiers in events. You can have events with the protected keyword,
which will be accessible only to inherited classes. You can have private
events only for objects in that class.
1. Why is the virtual keyword used in code?
The Virtual keyword is
used in code to define methods and the properties that can be overridden in
derived classes.
1. What are constructors and destructors?
Constructors and
destructors are special methods.
Constructors and
destructors are special methods of every class.
Each class has its own
constructor and destructor and are called automatically when the instance of a
class is created or destroyed.
The constructor
initializes all class members whenever you access the class and the destructor
destroys them when the objects are not required anymore.
1. How can we suppress a finalize method?
GC.SuppressFinalize()
1. Does C# support a variable number of arguments?
Yes, using the params
keyword.
The arguments are
specified as a list of arguments of a specific type, e.g., int. For ultimate
flexibility, the type can be object.
The standard example
of a method which uses this approach is System.console.writeLine().
107.Which
method will you call to start a thread?
Start
1. What is Generic?
Generic help us to
create flexible strong type collection.
Generic basically
seperate the logic from the datatype in order maintain better reusability,
better maintainability etc.
1. What are the different types of polymorphism?
There are two types of
polymorphism. They are:
Compile time
Polymorphism
Run time Polymorphism
1. What is the difference between compile time polymorphism and
run time polymorphism?
Compile
time Polymorphism
Compile time
Polymorphism also known as method overloading.
Method overloading
means having two or more methods with the same name but with different
signatures.
Run
time Polymorphism
Run time Polymorphism
also known as method overriding.
Method overriding
means having two or more methods with the same name , same signature but with
different implementation.
1. Which namespace enables multithreaded programming in XML?
System.Threading
1. Can we declare a block as static in c#?
No, because c# doesnot
support static block, but it supports static method.
1. Can we declare a method as sealed?
In C# a method can't
be declared as sealed. However when we override a method in a derived class, we
can declare the overridden method as sealed. By declaring it as sealed, we
can avoid further overriding of this method.
1. What Command is used to implement properties in C#?
get & set access
modifiers are used to implement properties in c#.
1. What is static member?
The member defined as
static which can be invoked directly from the class level, rather than from its
instance.
1. What is the syntax to inherit from a class in C#?
When a class is
derived from another class, then the members of the base class become the
members of the derived class.
The access modifier
used while accessing members of the base class specifies the access status of
the base class members inside the derived class.
The syntax to inherit
a class from another class In C# is as follows:
class MyNewClass :
MyBaseClass
1. What is a basic difference between the while loop and do
while loop in C#?
The while loop tests
its condition at the beginning, which means that the enclosed set of statements
run for zero or more number of times if the condition evaluates to true.
The do while loop iterates a set of statements at least once and then checks
the condition at the end.
1. What is the main difference between a subprocedure and a
function?
Subprocedures do not
return a value, while functions do.
1. What are sealed classes in c#?
The sealed modifier is
used to prevent derivation from a class.
A compile time error
occurs if a sealed class is specified as the base class of another class.
1. What is the difference between class and an Interface?
Abstract classes can
have implementations for some of its members, but the interface can't have
implementation for any of its members.
Interfaces cannot have
fields where as an abstract class can have fields.
An interface can
inherit from another interface only and cannot inherit from an abstract class,
where as an abstract class can inherit from another abstract class or
another interface.
A class can inherit
from multiple interfaces at the same time, where as a class cannot inherit from
multiple classes at the same time.
Abstract class members
can have access modifiers where as interface members cannot have access
modifiers.
1. What is the difference between an abstract method &
virtual method?
An Abstract method
does not provide an implementation and forces overriding to the deriving class
(unless the deriving class also an abstract class), where as the virtual
method has an implementation and leaves an option to override it in the
deriving class. Thus Virtual method has an implementation & provides
the derived class with the option of overriding it. Abstract method does not
provide an implementation & forces the derived class to override the
method.
1. What is Static Method?
It is possible to
declare a method as Static provided that they don't attempt to access any
instance data or other instance methods.
1. What is a New modifier?
The new modifier hides
a member of the base class. C# supports only hide by signature.
1. What are the advantages of get and set properties in C#?
The get property
accessor is used to return the property value.
The set property
accessor is used to assign a new value.
1. What are the difference between const and readonly?
A const need to be
declared and initialized at declaration only,
while a readonly can be initialized at declaration or by the code in the constructor.
while a readonly can be initialized at declaration or by the code in the constructor.
A const value is
evaluated at design time,
while a readonly's value is evaluated at runtime
while a readonly's value is evaluated at runtime
To ensure that no one has tampered with ViewState in a Web page, set the EnableViewStateMac property to True.
The PlaceHolder control acts as a container for those controls that are dynamically generated at runtime. We cannot see it at runtime because it does not produce any visible output. It used only as a container.
The server tells the browser to put some files in a cookie, and the client then sends all the cookies for the domain in each request. An example of cookie abuse is large cookies affecting the network traffic.
HTTP handlers, as the name suggests, are used to handle user requests for Web application resources. They are the backbone of the request-response model of Web applications. There is a specific event handler to handle the request for each user request type and send back the corresponding response object.Each user requests to the IIS Web server flows through the HTTP pipeline, which refers to a series of components
(HTTP modules and HTTP handlers) to process the request. HTTP modules act as filters to process the request as it passes through the HTTP pipeline. The request, after passing through the HTTP modules, is assigned to an HTTP handler that determines the response of the server to the user request. The response then passes through the HTTP modules once again and is then sent back to the user.You can define HTTP handlers in the element of a configuration file. The element tag is used to add new handlers and the element tag is used to remove existing handlers. To create an HTTP handler, you need to define a class that implements the IHttpHandler interface.
The Page.Validate() method is used to force all the validation controls to run and to perform validation.
Tracing displays the details about how the code was executed. It refers to collecting information about the application while it is running. Tracing information can help you to troubleshoot an application. It enables you to record information in various log files about the errors that might occur at run time. You can analyze these log files to find the cause of the errors.In .NET, we have objects called Trace Listeners. A listener is an object that gets the trace output and stores it to different places, such as a window, a file on your locale drive, or a SQL Server.The System.Diagnostics namespace contains the predefined interfaces, classes, and structures that are used for tracing. It supplies two classes, Trace and Debug, which allow you to write errors and logs related to the application execution. Trace listeners are objects that collect the output of tracing processes.