.Net Interview Questions and Answers Volume-III
|
|
What is the difference
between Overloading and Shadowing?
|
||||||||||
|
Overloading : A Member
has the name, but something else in the signature is different.
Shadowing : A member shadows another member if the derived member replaces the base member |
|||||||||||
|
|
What is the difference
between Overloading and Overriding?
|
||||||||||
|
Overloading : Method
name remains the same with different signatures.
Overriding : Method name and Signatures must be the same. |
|||||||||||
|
|
what is Boxing and
Unboxing?
|
||||||||||
|
Boxing is an implicit
conversion of a value type to the type object
int i = 123; // A value type Object box = i // Boxing -------------------------------------------------------------------------------- Unboxing is an explicit conversion from the type object to a value type int i = 123; // A value type Object box = i; // Boxing int j = (int)box; // Unboxing |
|||||||||||
|
|
what is the difference
between array and arraylist?
|
||||||||||
|
Arrays are always fixed
size in nature and ArrayList can grow dynamically.
|
|||||||||||
|
|
what is the difference
between readonly and constant varaibles??
|
||||||||||
|
readonly - variables are
dynamic constant, you can modify the value in the constructor only.
constant - variables are constant, you cannot change the values once its declared as a constant. |
|||||||||||
|
|
What is enum?
|
||||||||||
|
An enum type is a
distinct type that declares a set of named constants.They are strongly typed
constants. They are unique types that allow to declare symbolic names to
integral values.
public enum Grade { A, B, C } |
|||||||||||
|
|
What is the life cycle
for an object?
|
||||||||||
|
1. The object is
created.
2. Memory is allocated for the object. 3. The constructor is run. 4. The object is now live. 5. if the object is no longer in use, it needs finalization. 6. Finalizers are run. 7. The object is now inaccessible and is available for the garbage collector to carry out clean-up. 8. The garbage collector frees up associated memory. |
|||||||||||
|
|
What is CodeDOM?
|
||||||||||
|
CodeDOMis an object model, which is used to
generate a source code. It is designed to be language independent - once you
create a CodeDom hierarchy for a program we can then generate the source code
in any .NET complaint language.
|
|||||||||||
|
|
What is Static class?
|
||||||||||
|
1.A static class can
only contain static members.
2.We cannot create an instance of a static class. 3.Static class is always sealed and they cannot contain instance constructor 4.Hence we can also say that creating a static class is nearly same as creating a class with only static members and a private constructor (private constructor prevents the class from being instantiated). ---Good example is the System.Math class |
|||||||||||
|
|
What are method
parameters in C#?
|
||||||||||
|
C# is having 4 parameter
types which are
1.Value Parameter. default parameter type. Only Input 2.Reference(ref) Parameter. Input\Output 3.Output(out) Parameter. 4.Parameter(params) Arrays |
|||||||||||
|
|
How to
get the Assembly version programatically?
|
||||||||||
|
System.Reflection.AssemblyName
myAssemblyName = System.Reflection.AssemblyName.GetAssemblyName(@"D:\SepTest\Bin\Ajax.dll");
MessageBox.Show(myAssemblyName.Version.ToString()); |
|||||||||||
|
|
What is
delay signing?
|
||||||||||
|
Delay
signing allows you to place a shared assembly in the GAC by signing the
assembly with just the public key. This allows the assembly to be signed with
the private key at a later stage, when the development process is complete
and the component or assembly is ready to be deployed.
|
|||||||||||
|
|
What is
partial class?
|
||||||||||
|
- The
partial classes use the new keyword partial and are defined in the same
namespace.
- partial classes as a class definition split across many files for convenience - Partial classes must use the same access modifier (for example Public Protected and Private). - If any single part is abstract (MustInherit), the whole class is abstract. - If any parts are sealed (NotInheritable), the whole class is sealed. - If any part declares a base type, the whole class inherits that base type. - Parts can specify different interfaces, but the whole class implements all interfaces. - Delegates and enumerations cannot use the partial modifier. |
|||||||||||
|
|
What is
Generics in C#?
|
||||||||||
|
Parametric
Polymorphism is a well-established programming language feature. Generics
offers this feature to C#.
The concept is very close to Templates in C++. In the generic List<T> collection, in System.Collections.Generic namespace, the same operation of adding items to the collection looks like this:
// The .NET Framework 2.0 way of
creating a list
List<int> list1 = new
List<int>();
list1.Add(3); // No boxing, no
casting
list1.Add("First
item"); // Compile-time error
|
|||||||||||
|
|
What is
Anonymous method in C#(.NET 2.0)?
|
||||||||||
|
Anonymous
methods is a new feature in C# 2.0 that lets you define an anonymous (that
is, nameless) method called by a delegate.
For example, the following is a conventional
SomeMethod method definition and delegate invocation:
class SomeClass
{
delegate void SomeDelegate();
public void InvokeMethod()
{
SomeDelegate del = new
SomeDelegate(SomeMethod);
del();
}
void SomeMethod()
{
MessageBox.Show("Hello");
}
}
You can
define and implement this with an anonymous method:
class SomeClass
{
delegate void SomeDelegate();
public void InvokeMethod()
{
SomeDelegate del = delegate()
{
MessageBox.Show("Hello");
};
del();
}
}
The anonymous method is defined in-line and not as
a member method of any class. Additionally, there is no way to apply method
attributes to an anonymous method, nor can the anonymous method define
generic types or add generic constraints.
Anonymous methods can be used anywhere that a
delegate type is expected. You can pass an anonymous method into any method
that accepts the appropriate delegate type as a parameter:
|
|||||||||||
|
|
what are
the different levels Thread priority provided by .NET?
|
||||||||||
|
-
ThreadPriority.Highest
- ThreadPriority.AboveNormal - ThreadPriority.Normal - ThreadPriority.BelowNormal - ThreadPriority.Lowest We can change the thread priority setting by Threadname.Priority=ThreadPriority.Highest |
|||||||||||
|
|
What is
event bubbling?
|
||||||||||
|
Server
Controls like datagrid, Datalist, Repeater can have child controls inside
them.For example Combo box inside datagrid. The Child controls(combo box)
send their events to parent(datagrid) is known as event bubbling.
|
|||||||||||
|
|
what are
the serialization types supported in .NET?
|
||||||||||
|
Serialization
is the process of saving the state of an object by converting it to a stream
of bytes. The object can then be persisted to file, database, or even memory.
The reverse process of serialization is known as deserialization.
The serialization types are as follows 1. XML serialization 2. Binary serialization 3. Soap serialization. Code snippet for XML serialization
Code
snippet for Binary serialization
Code
snippet for Soap serialization
|
|||||||||||
|
|
What is
Array?
|
||||||||||
|
Example
of Single Dimension Array in .Net
int [] intArray = new int[3]; intArray[2] = 22; // set the third element to 22 Example of Multi Dimension Array in .Net int [][] myTable = new int[2,3]; myTable[1,2] = 22; Example of Jagged Array in .Net : Variable Length Array in .Net int [][] myTable = new int[3][]; myTable[0] = new int[5]; myTable[1] = new int[2]; myTable[2] = new int[4]; myTable[0][2] = 11; Example of String Array in .Net string []names = new string[4]; names[2] = “God will make me win”; Limitation of Arrays -->The size of an array is always fixed and must be defined at the time of instantiation of an array. -->Secondly, an array can only contain objects of the same data type, which we need to define at the time of its instantiation. |
|||||||||||
|
|
What is
Nullable Type in .Net 2.0?
|
||||||||||
|
Nullable
in .Net 2.0, helps to determine whether variable has been assigned a value or
not. Example: Quiz application having option yes/no, but it should displayed
“Not Attempted” when user does not make any choice.
Syntax : Nullable b = null //only for C# bool? b = null; Example : if (b.HasValue) Console.WriteLine("User has Attempted Given Question"); else Console.WriteLine("User has not Attempted Given Question"); |
|||||||||||
|
|
What is
the difference between out and ref parameter?
|
||||||||||
|
Difference
is that out parameters need to be declared but not initialized.
ref parameter will have a value even before the method call.. |
|||||||||||
|
|
what is
the Concept of heap and stack?
|
||||||||||
|
|||||||||||
|
|
what are
value types and reference types?
|
||||||||||
|
|||||||||||
|
|
What are
primitive data types?
|
||||||||||
|
Primitive
data types are basic data types. C# is having 15 primitive data types
Value types - 13 boolean, byte, char, double, decimal, float, int, long, short, sbyte, ushort, uint, ulong Ref types - 2 string and object |
|||||||||||
|
|
what are
the differences between string and stringbuilder?
|
||||||||||
|
|||||||||||
|
|
what is
the difference between Manifest and Metadata?
|
||||||||||
|
|||||||||||
|
|
what is
the difference between abstract class and interface?
|
||||||||||
|
|||||||||||
|
|
What are
the access modifiers in C#
|
||||||||||
|
There
are Four access modifiers
public : Members are fully accessible protected : A protected member is accessible from within the class in which it is declared internal : Internal members are accessible only within files in the same assembly private : Private members are accessible only within the body of the class |
|||||||||||
|
|
What are
the Accessibility levels in C#
|
||||||||||
|
There
are five Accessibility levels
public : Access is not restricted. protected : Access is limited to the containing class or types derived from the containing class. internal : Access is limited to the current assembly. protected internal : Access is limited to the current assembly or types derived from the containing class. private : Access is limited to the containing type. |
|||||||||||
|
|
What is
Dispose method in .NET?
|
||||||||||
|
.NET
provides "Finalize" method in which we can clean up our resources.
But relying on this is not always good so the best is to implement
"IDisposable" interface and implement the "Dispose"
method where you can put your clean up routines
|
|||||||||||
|
|
What is CLR??
|
||||||||||
|
The CLR(Common Language
Runtime) Responsibilities are
√ Garbage Collection √ Code Access Security √ Code Verification √ IL( Intermediate language )-to-native translators and optimizer’s |
|||||||||||
|
|
What is CAS?
|
||||||||||
|
.NET has two kinds of
security:
--Role Based Security --Code Access Security ====================== CAS is the CLR's security system that enforces security policies by preventing unauthorized access to protected resources and operations. Using the Code Access Security, you can do the following: -Restrict what your code can do -Restrict which code can call your code Code access security consists of the following elements: permissions - FileIOPermission (when working with files), UIPermission (permission to use a user interface), SecurityPermission (this is needed to execute the code. permission sets - FullTrust, LocalIntranet, Internet, Execution and Nothing are some of the built in permission sets in .NET Framework code groups - My_Computer_Zone, LocalIntranet_Zone, Internet_Zone policy - There are four policy levels - Enterprise, Machine, User and Application Domain We can acheieve CAS in two ways : from the .NET Configuration Tool or from the command prompt using caspol.exe. First we'll do this using the .NET Configuration Tool. Go to Control Panel --> Administrative Tools --> Microsoft .NET Framework Configuration |
|||||||||||
|
|
What are the Garbage
collector Responsiblities in .NET?
|
||||||||||
|
GC take the
responsibility of tracking memory usage.
The .NET garbage collector is optimized for the following assumptions 1. Objects that were recently allocated are most likely to be freed. 2. Objects that have lived the longest are least likely to be become free. 3. Objects allocated together are often used together. The objects allocated are categorized into three generations. Most recently allocated objects are placed in generation 0. Objects in generation 0, that survive a garbage collection pass are moved to generation 1. generation 2 contains long-lived objects, that survive after the two collection passes. |
|||||||||||
|
|
What is the difference
between Indexers and Properties?
|
||||||||||
|
1. An indexer is
identified by it's signature. But a property is identified it's name.
2. An indexer is always an instance member, but a property can be static also. 3. An indexer is accessed through an element access. But a property is through a member access. |
|||||||||||
|
|
What is thread pooling?
|
||||||||||
|
You can hook up methods
to the ThreadPool by using QueueUserWorkItem.
You have your method you want to run on the threads, and you must hook it up to QueueUserWorkItem. How can you do this? You must use WaitCallback. At MSDN, WaitCallback is described as a delegate callback method to be called when the ThreadPool executes. It is a delegate that "calls back" its argument. Use WaitCallback In this part, we see that you can use WaitCallback by simply specifying the "new WaitCallback" syntax as the first argument to ThreadPool.QueueUserWorkItem. You don't need any other code here. void Example() { // Hook up the ProcessFile method to the ThreadPool. // Note: 'a' is an argument name. Read more on arguments. ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessFile), a); } private void ProcessFile(object a) { // I was hooked up to the ThreadPool by WaitCallback. } |
|||||||||||
|
|
What is early and late
binding?
|
||||||||||
|
Everything is early
bound in C# unless you go through the Reflection interface.
Most script languages use late binding, and compiled languages use early binding. Early bound just means the target method is found at compile time. Late bound means the target method is looked up at run time Binding usually has an effect on performance. Because late binding requires lookups at runtime, it is usually means method calls are slower than early bound method calls. |
|||||||||||
|
|
What is Extension
methods C#?
|
||||||||||
|
Extension methods enable
you to "add" methods to existing types without creating a new
derived type, recompiling, or otherwise modifying the original type.
An extension method is a static method of a static class, where the this modifier is applied to the first parameter. The type of the first parameter will be the type that is extended. namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int x = 3; Console.WriteLine(x.factorial()); Console.ReadLine(); } } public static class MyMathExtension { public static int factorial(this int x) { if (x <= 1) return 1; if (x == 2) return 2; else return x * factorial(x - 1); } } } |
|||||||||||
|
|
What is encapsulation in
C#?
|
||||||||||
|
Encapsulation means to
wrapping up the data and methods into single unit.
C# provides accessor methods (get and set methods) which are used to achieve the encapsulation in the C#. we can hide the data by making the access modifier private: Encapsulation provides a way to protect data from accidental corruption. Rather than defining the data in the form of public, we can declare those fields as private The Two ways we can acheive encapsulation by
|
|||||||||||
|
|
What is the difference
between arraylist and Generics C#?
|
||||||||||
|
By creating a generic
class, you can create a collection that is type-safe at compile-time.
Any reference or value type that is added to an ArrayList is implicitly upcast to Object. If the items are value types, they must be boxed when added to the list, and unboxed when they are retrieved.
|
|||||||||||
Other Interview
Questions
- How many languages .NET is supporting now?
- How is .NET able to support multiple languages?
- How ASP .NET different from ASP?
- What is smart navigation?
- What is view state?
- How do you validate the controls in an ASP .NET page?
- Can the validation be done in the server side? Or this
can be done only in the Client side?
- How to manage pagination in a page?
- What is ADO .NET and what is difference between ADO and
ADO.NET?
- Explain the differences between Server-side and
Client-side code?
- What type of code (server or client) is found in a
Code-Behind class?
- Should validation (did the user enter a real date) occur
server-side or client-side? Why?
- What does the "EnableViewState" property do?
Why would I want it on or off?
- What is the difference between Server.Transfer and
Response.Redirect?
- Can you give an example of when it would be appropriate
to use a web service as opposed to a non-serviced .NET component?
- Can you explain the difference between an ADO.NET
Dataset and an ADO Recordset?
- Can you give an example of what might be best suited to
place in the Application_Start and Session_Start subroutines?
- What are ASP.NET Web Forms? How is this technology
different than what is available though ASP?
- How does VB.NET/C# achieve polymorphism?
- Can you explain what inheritance is and an example of
when you might use it?
- How would you implement inheritance using VB.NET/C#?
- Whats an assembly?
- Describe the difference between inline and code behind -
which is best in a loosely coupled solution?
- Explain what a diffgram is, and a good use for one?
- Where would you use an iHTTPModule, and what are the
limitations of anyapproach you might take in implementing one?
- In what order do the events of an ASPX page execute. As
a developer is it important to undertsand these events?
- Which method do you invoke on the DataAdapter control to
load your generated dataset with data?
- Which template must you provide, in order to display
data in a Repeater control?
- How can you provide an alternating color scheme in a
Repeater control?
- What property must you set, and what method must you
call in your code, in order to bind the data from some data source to the
Repeater control?
- What base class do all Web Forms inherit from?
- What method do you use to explicitly kill a user’s
session?
- How do you turn off cookies for one page in your site?
- Which two properties are on every validation control?
- How do you create a permanent cookie?
- Which method do you use to redirect the user to another
page without performing a round trip to the client?
- What is the transport protocol you use to call a Web
service?
- True or False: A Web service can only be written in
.NET.?
- What does WSDL stand for?
- Where on the Internet would you look for Web services?
- What tags do you need to add within the asp:datagrid
tags to bind columns manually?
- How is a property designated as read-only?
- Which control would you use if you needed to make sure
the values in two different controls matched?
- True or False: To test a Web service you must create a
windows application or Web application to consume this service?
- How many classes can a single .NET DLL contain?
- Describe session handling in a webfarm, how does it work
and what are the limits?
- What are the disadvantages of viewstate/what are the
benefits?
- What tags do you need to add within the asp:datagrid
tags to bind columns manually?
- What is State Management in .Net and how many ways are
there to maintain a state in .Net? What is view state?
- What tag do you use to add a hyperlink column to the
DataGrid?
- What is the standard you use to wrap up a call to a Web
service?
- What is the difference between boxing and unboxing?
- Describe the difference between a Thread and a Process?
- What is a Windows Service and how does its lifecycle
differ from a “standard” EXE?
- What is the difference between an EXE and a DLL?
- What is strong-typing versus weak-typing? Which is
preferred? Why?
- What are PDBs? Where must they be located for debugging
to work?
- What is cyclomatic complexity and why is it important?
- What is FullTrust? Do GAC’ed assemblies have FullTrust?
- What does this do? gacutil /l | find /i “about”
- Contrast OOP and SOA. What are tenets of each
- How does the XmlSerializer work? What ACL permissions
does a process using it require?
- Why is catch(Exception) almost always a bad idea?
- What is the difference between Debug.Write and
Trace.Write? When should each be used?
- What is the difference between a Debug and Release
build? Is there a significant speed difference? Why or why not?
- Contrast the use of an abstract base class against an
interface?
- What is the difference between a.Equals(b) and a == b?
- How would one do a deep copy in .NET?
- What is boxing?
- Is string a value type or a reference type?
- How does the lifecycle of Windows services differ from
Standard EXE?
- What’s wrong with a line like this?
DateTime.Parse(myString)
- NET is Compile Time OR RunTime Environment?
- Describe the role of inetinfo.exe, aspnet_isapi.dll
andaspnet_wp.exe in the page loading process.
- What’s the difference between Response.Write()
andResponse.Output.Write()?
- What methods are fired during the page load?
- Where does the Web page belong in the .NET Framework
class hierarchy?
- Where do you store the information about the user’s
locale?
- What’s the difference between
Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?
- What’s a bubbled event?
- Suppose you want a certain ASP.NET function executed on
MouseOver overa certain button. Where do you add an event handler?
- What data type does the RangeValidator control support?
- Which of the following languages is NOT included in the
default .NET Framework installation?
- What are the different types of serialization supported
in .NET Framework...
- The CLR uses which format for assembly version numbers
...
- What tool is used to manage the GAC?
- State True or False: A single .NET dll can contain
unlimited classes: * True or * False?
- State True or False: ASP.NET can currently run only on
Windows Platform: * True or * False?
- Which one of the following best describes “Type-Safe”
- The number of objects in ASP.NET is ...
- The code used to turn off buffering is * Buffering =
false...
- Can you have two applications on the same machine one
which is using .NET Framework 1.1 and the other using 2.0 ?
- Which of the following DOT.NET tools manages
certificates, certificate trust lists (CTLs), and certificate revocation
lists (CRLs)?
- You need to generate a public/private key pair for using
in creating a shared assembly. Given the above scenario, which .NET SDK
utility should be used?
- The object that contains all the properties and methods
for every ASP.NET page, that is built is ..
- In C#, which character is used to indicate a verbatim
string literal?
- Which of the following operators has the highest
precedence?
- The uniqueId that gets generated at the start of the
Session is stored in ...
- State True or False: C# supports multiple-inheritance: *
True or * False?
- Bitwise AND operator in C# is ...
- Bitwise OR operator in C# is ...
- What’s the .NET datatype that allows the retrieval of
data by a unique key?
- The keyword ‘int’ maps to one of the following .NET type
...
- What can be achieved in IL which is not possible in C# ?
- Which of the following is the correct code for setting a
Session timeout of 30 minutes
- The process that ASP.NET uses to keep track of Sessions
without cookies is ..,
- The method that transfers ASP.NET execution to another
page, but returns to the original page when it is done is ...
- A structure in C# can be derived from one or more ...
- State True or False: Static method cannot be overridden:
* True or * False
- The Equivalent HTML Control for the <input
type=”button”> tag is ..
- The Equivalent Html Control for the <input
type=”checkbox”> tag is
- Which operator is used for connecting a event with a
procedure in C#?
- The Equivalent Html Control for the <select> tag
is ...
- State True or False: Events in Web forms are processed
before the “Page Load” event: * True or * False
- What namespaces are necessary to create a localized
application?
- A new server-side control can be created by implementing
the class ___________
- The parameter “clienttarget = downlevel” does one of the
following ...
- The methods in C# can be overloaded in which of the
following ways
- The RangeValidator control supports the following
datatype ...
- What is the difference between Convert.ToInt32 and
int.Parse?
- State True or False: Any ODBC-compliant database can be
accessed through ASP.NET: * True or * False
- You need to select a .NET language that has
auto-documenting features built into the source code and compiler ...
- A set of tables are maintained in a Dataset as ...
- The namespaces needed to use data mechanisms in ASP.NET
pages are...
- What are the different methods to access Database in
.NET ?
- The two properties of a DataGrid that has to be
specified to turn on sorting and paging respectively are ...
- Which one of the following objects is used to create a
foreign key between two DataTables?
- The Syntax for data-binding expressions is ...
- The method that need to be invoked on the DataAdapter
control to load the generated dataset with data is
- Which of the following operations can you NOT perform on
an ADO.NET DataSet?
- Which is the correct statement to set the alias name for
namespace in C#?
- The property that indicates whether existing database
constraints should be observed when performing updates
- If you set AutoGenerateColumns=True and still provide
custom column definitions ...
- The data from an XSL Transform with XmlReader can be
returned in one of the following ways
- Pick the command line that would result in the C#
compiler generating an XML documentation file ...
- What is the comment syntax for C#’s XML-based
documentation?
- When creating a C# Class Library project, what is the
name of the supplementary file ...
- Which of the following is the C# escape character for
Null?
- What is the exception that is thrown when there is an
attempt to dynamically access a method that does not exist?
- What method(s) must be used with the Application object
to ensure that only one process accesses a variable at a time?
- After capturing the SelectedIndexChanged event for a
ListBox control, you find that the event handler doesn’t execute. What could
the problem be?
- What method must be overridden in a custom control?
- What is used to validate complex string patterns like an
e-mail address?
- The following is a valid statement in ASP.NET<%@ Page
Language="C" %>: * True or * False
- A valid comment block in ASP.NET is ...
- The event handlers that can be included in the
Global.asax file are ...
- A Few of the Namespaces that get imported by default in
an ASPX file are ...
- The Assemblies that can be referenced in an ASPX file
without using @Assembly Directive is ...
- An .ASHX file contains the following ...
- What is the output for the following code snippet:..
- One of the possible way of writing an ASP.NET handler
that works like an ISAPI filter- that is ...
- The ASP.NET directive that lets you cache different
versions of a page based on varying input parameters ...
- If we develop an application that must accommodate
multiple security levels through secure login and ASP.NET web application
is spanned across three web-servers (using round-robin load balancing)
what would be the best approach to maintain login-in state for the users?
- What is the output for the below mentioned compilation
command>csc /addmodule:A.Exe B.Cs
- How can be the web application get configured with the
following authorization rules ...
- What will be the output of the following code snippet?
- What will be output for the given code?
Short
Answer .NET Interview Questions (PAGE 2)
Q21. What is encapsulation?
Ans. Encapsulation is the OOPs concept of binding the attributes and behaviors in a class, hiding the implementation of the class and exposing the functionality. Q22. What is Overloading? Ans. When we add a new method with the same name in a same/derived class but with different number/types of parameters, the concept is called overluoad and this ultimately implements Polymorphism. Q23. What is Overriding? Ans. When we need to provide different implementation in a child class than the one provided by base class, we define the same method with same signatures in the child class and this is called overriding. Q24. What is a Delegate? Ans. A delegate is a strongly typed function pointer object that encapsulates a reference to a method, and so the function that needs to be invoked may be called at runtime. Q25. Is String a Reference Type or Value Type in .NET? Ans. String is a Reference Type object. Q26. What is a Satellite Assembly? Ans. Satellite assemblies contain resource files corresponding to a locale (Culture + Language) and these assemblies are used in deploying an application globally for different languages. Q27. What are the different types of assemblies and what is their use? Ans. Private, Public(also called shared) and Satellite Assemblies. Q28. Are MSIL and CIL the same thing? Ans. Yes, CIL is the new name for MSIL. Q29. What is the base class of all web forms? Ans. System.Web.UI.Page Q30. How to add a client side event to a server control? Ans. Example... BtnSubmit.Attributes.Add("onclick","javascript:fnSomeFunctionInJavascript()"); Q31. How to register a client side script from code-behind? Ans. Use the Page.RegisterClientScriptBlock method in the server side code to register the script that may be built using a StringBuilder. Q32. Can a single .NET DLL contain multiple classes? Ans. Yes, a single .NET DLL may contain any number of classes within it. Q33. What is DLL Hell? Ans. DLL Hell is the name given to the problem of old unmanaged DLL's due to which there was a possibility of version conflict among the DLLs. Q34. can we put a break statement in a finally block? Ans. The finally block cannot have the break, continue, return and goto statements. Q35. What is a CompositeControl in .NET? Ans. CompositeControl is an abstract class in .NET that is inherited by those web controls that contain child controls within them. Q36. Which control in asp.net is used to display data from an xml file and then displayed using XSLT? Ans. Use the asp:Xml control and set its DocumentSource property for associating an xml file, and set its TransformSource property to set the xml control's xsl file for the XSLT transformation. Q37. Can we run ASP.NET 1.1 application and ASP.NET 2.0 application on the same computer? Ans. Yes, though changes in the IIS in the properties for the site have to be made during deployment of each. Q38. What are the new features in .NET 2.0? Ans. Plenty of new controls, Generics, anonymous methods, partial classes, iterators, property visibility (separate visibility for get and set) and static classes. Q39. Can we pop a MessageBox in a web application? Ans. Yes, though this is done clientside using an alert, prompt or confirm or by opening a new web page that looks like a messagebox. Q40. What is managed data? Ans. The data for which the memory management is taken care by .Net runtimeĆ¢€™s garbage collector, and this includes tasks for allocation de-allocation.
Q41. How to instruct the garbage
collector to collect unreferenced data?
Ans. We may call the garbage collector to collect unreferenced data by executing the System.GC.Collect() method. Q42. How can we set the Focus on a control in ASP.NET? Ans. txtBox123.Focus(); OR Page.SetFocus(NameOfControl); Q43. What are Partial Classes in Asp.Net 2.0? Ans. In .NET 2.0, a class definition may be split into multiple physical files but partial classes do not make any difference to the compiler as during compile time, the compiler groups all the partial classes and treats them as a single class. Q44. How to set the default button on a Web Form? Ans. <asp:form id="form1" runat="server" defaultbutton="btnGo"/> Q45.Can we force the garbage collector to run? Ans. Yes, using the System.GC.Collect(), the garbage collector is forced to run in case required to do so. Q46. What is Boxing and Unboxing? Ans. Boxing is the process where any value type can be implicitly converted to a reference type object while Unboxing is the opposite of boxing process where the reference type is converted to a value type. Q47. What is Code Access security? What is CAS in .NET? Ans. CAS is the feature of the .NET security model that determines whether an application or a piece of code is permitted to run and decide the resources it can use while running. Q48. What is Multi-tasking? Ans. It is a feature of operating systems through which multiple programs may run on the operating system at the same time, just like a scenario where a Notepad, a Calculator and the Control Panel are open at the same time. Q49. What is Multi-threading? Ans. When an application performs different tasks at the same time, the application is said to exhibit multithreading as several threads of a process are running.2 Q50. What is a Thread? Ans. A thread is an activity started by a process and its the basic unit to which an operating system allocates processor resources. Q51. What does AddressOf in VB.NET operator do? Ans. The AddressOf operator is used in VB.NET to create a delegate object to a method in order to point to it. Q52. How to refer to the current thread of a method in .NET? Ans. In order to refer to the current thread in .NET, the Thread.CurrentThread method can be used. It is a public static property. Q53. How to pause the execution of a thread in .NET? Ans. The thread execution can be paused by invoking the Thread.Sleep(IntegerValue) method where IntegerValue is an integer that determines the milliseconds time frame for which the thread in context has to sleep. Q54. How can we force a thread to sleep for an infinite period? Ans. Call the Thread.Interupt() method. Q55. What is Suspend and Resume in .NET Threading? Ans. Just like a song may be paused and played using a music player, a thread may be paused using Thread.Suspend method and may be started again using the Thread.Resume method. Note that sleep method immediately forces the thread to sleep whereas the suspend method waits for the thread to be in a persistable position before pausing its activity. Q56. How can we prevent a deadlock in .Net threading? Ans. Using methods like Monitoring, Interlocked classes, Wait handles, Event raising from between threads, using the ThreadState property. Q57. What is Ajax? Ans. Asyncronous Javascript and XML - Ajax is a combination of client side technologies that sets up asynchronous communication between the user interface and the web server so that partial page rendering occur instead of complete page postbacks. Q58. What is XmlHttpRequest in Ajax? Ans. It is an object in Javascript that allows the browser to communicate to a web server asynchronously without making a postback. Q59. What are the different modes of storing an ASP.NET session? Ans. InProc (the session state is stored in the memory space of the Aspnet_wp.exe process but the session information is lost when IIS reboots), StateServer (the Session state is serialized and stored in a separate process call Viewstate is an object in .NET that automatically persists control setting values across the multiple requests for the same page and it is internally maintained as a hidden field on the web page though its hashed for security reasons. Q60. What is a delegate in .NET? Ans. A delegate in .NET is a class that can have a reference to a method, and this class has a signature that can refer only those methods that have a signature which complies with the class.
Short Answer .NET Interview Questions (PAGE 4)
Q61. Is a delegate a type-safe
functions pointer?
Ans. Yes Q62. What is the return type of an event in .NET? Ans. There is No return type of an event in .NET. Q63. Is it possible to specify an access specifier to an event in .NET? Ans. Yes, though they are public by default. Q64. Is it possible to create a shared event in .NET? Ans. Yes, but shared events may only be raised by shared methods. Q65. How to prevent overriding of a class in .NET? Ans. Use the keyword NotOverridable in VB.NET and sealed in C#. Q66. How to prevent inheritance of a class in .NET? Ans. Use the keyword NotInheritable in VB.NET and sealed in C#. Q67. What is the purpose of the MustInherit keyword in VB.NET? Ans. MustInherit keyword in VB.NET is used to create an abstract class. Q68. What is the access modifier of a member function of in an Interface created in .NET? Ans. It is always public, we cant use any other modifier other than the public modifier for the member functions of an Interface. Q69. What does the virtual keyword in C# mean? Ans. The virtual keyword signifies that the method and property may be overridden. Q70. How to create a new unique ID for a control? Ans. ControlName.ID = "ControlName" + Guid.NewGuid().ToString(); //Make use of the Guid class Q71A. What is a HashTable in .NET? Ans. A Hashtable is an object that implements the IDictionary interface, and can be used to store key value pairs. The key may be used as the index to access the values for that index. Q71B. What is an ArrayList in .NET? Ans. Arraylist object is used to store a list of values in the form of a list, such that the size of the arraylist can be increased and decreased dynamically, and moreover, it may hold items of different types. Items in an arraylist may be accessed using an index. Q72. What is the value of the first item in an Enum? 0 or 1? Ans. 0 Q73. Can we achieve operator overloading in VB.NET? Ans. Yes, it is supported in the .NET 2.0 version, the "operator" keyword is used. Q74. What is the use of Finalize method in .NET? Ans. .NET Garbage collector performs all the clean up activity of the managed objects, and so the finalize method is usually used to free up the unmanaged objects like File objects, Windows API objects, Database connection objects, COM objects etc. Q75. How do you save all the data in a dataset in .NET? Ans. Use the AcceptChanges method which commits all the changes made to the dataset since last time Acceptchanges was performed. Q76. Is there a way to suppress the finalize process inside the garbage collector forcibly in .NET? Ans. Use the GC.SuppressFinalize() method. Q77. What is the use of the dispose() method in .NET? Ans. The Dispose method in .NET belongs to IDisposable interface and it is best used to release unmanaged objects like File objects, Windows API objects, Database connection objects, COM objects etc from the memory. Its performance is better than the finalize() method. Q78. Is it possible to have have different access modifiers on the get and set methods of a property in .NET? Ans. No we can not have different modifiers of a common property, which means that if the access modifier of a property's get method is protected, and it must be protected for the set method as well. Q79. In .NET, is it possible for two catch blocks to be executed in one go? Ans. This is NOT possible because once the correct catch block is executed then the code flow goes to the finally block. Q80. Is there any difference between System.String and System.StringBuilder classes? Ans. System.String is immutable by nature whereas System.StringBuilder can have a mutable string in which plenty of processes may be performed.
Short Answer .NET Interview Questions (PAGE 5)
Q81. What technique is used to
figure out that the page request is a postback?
Ans. The IsPostBack property of the page object may be used to check whether the page request is a postback or not. IsPostBack property is of the type Boolean. Q82. Which event of the ASP.NET page life cycle completely loads all the controls on the web page? Ans. The Page_load event of the ASP.NET page life cycle assures that all controls are completely loaded. Even though the controls are also accessible in Page_Init event but here, the viewstate is incomplete. Q83. How is ViewState information persisted across postbacks in an ASP.NET webpage? Ans. Using HTML Hidden Fields, ASP.NET creates a hidden field with an ID="__VIEWSTATE" and the value of the page's viewstate is encoded (hashed) for security. Q84. What is the ValidationSummary control in ASP.NET used for? Ans. The ValidationSummary control in ASP.NET displays summary of all the current validation errors. Q85. What is AutoPostBack feature in ASP.NET? Ans. In case it is required for a server side control to postback when any of its event is triggered, then the AutoPostBack property of this control is set to true. Q86. What is the difference between Web.config and Machine.Config in .NET? Ans. Web.config file is used to make the settings to a web application, whereas Machine.config file is used to make settings to all ASP.NET applications on a server(the server machine). Q87. What is the difference between a session object and an application object? Ans. A session object can persist information between HTTP requests for a particular user, whereas an application object can be used globally for all the users. Q88. Which control has a faster performance, Repeater or Datalist? Ans. Repeater. Q89. Which control has a faster performance, Datagrid or Datalist? Ans. Datalist. Q90. How to we add customized columns in a Gridview in ASP.NET? Ans. Make use of the TemplateField column. Q91. Is it possible to stop the clientside validation of an entire page? Ans. Set Page.Validate = false; Q92. Is it possible to disable client side script in validators? Ans. Yes. simply EnableClientScript = false. Q93. How do we enable tracing in .NET applications? Ans. <%@ Page Trace="true" %> Q94. How to kill a user session in ASP.NET? Ans. Use the Session.abandon() method. Q95. Is it possible to perform forms authentication with cookies disabled on a browser? Ans. Yes, it is possible. Q96. What are the steps to use a checkbox in a gridview? Ans. <ItemTemplate> <asp:CheckBox id="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="Check_Clicked"></asp:CheckBox> </ItemTemplate> Q97. What are design patterns in .NET? Ans. A Design pattern is a repeatitive solution to a repeatitive problem in the design of a software architecture. Q98. What is difference between dataset and datareader in ADO.NET? Ans. A DataReader provides a forward-only and read-only access to data, while the DataSet object can carry more than one table and at the same time hold the relationships between the tables. Also note that a DataReader is used in a connected architecture whereas a Dataset is used in a disconnected architecture. Q99. Can connection strings be stored in web.config? Ans. Yes, in fact this is the best place to store the connection string information. Q100. Whats the difference between web.config and app.config? Ans. Web.config is used for web based asp.net applications whereas app.config is used for windows based applications.
|
|||||||||||||||||||||||||||||||||||||||||||||||