ξσ Dicky's Blog σξ

朋友多了,寂寞卻沒少,朋友沒有了你,得到了天下最高的技術又能如何?人類的全部才能無非是時間和耐心的混合物.---巴尔扎克

Traditional Chinese

导航

.NET Interview Questions And Answers

  • · Differences

1. Difference between Classic ASP and ASP.Net?
Answer:

§ ASP is Interpreted language based on scripting languages like Jscript or VBScript.

§ ASP has Mixed HTML and coding logic.

§ Limited development and debugging tools available.

§ Limited OOPS support.

§ Limited session and application state management.

§ Poor Error handling system.

§ No in-built support for XML.

§ No fully distributed data source support.
while

§ ASP.Net is supported by compiler and has compiled language support.

§ Separate code and design logic possible.

§ Variety of compilers and tools available including the Visual studio.Net.

§ Completely Object Oriented.

§ Complete session and application state management.

§ Full proof error handling possible.

§ Full XML Support for easy data exchange.

§ Fully distributed data source support.

2. What’s the difference between Response.Write() and Response.Output.Write()?
Answer: Response.Outout.Write allows us to write the formatted out put.

3. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
Answer:

§ A DataSet can represent an entire relational database in memory, complete with tables, relations, and views, A Recordset can not.

§ A DataSet is designed to work without any continuing connection to the original data source; Recordset maintains the contentious connection with the original data source.

§ There’s no concept of cursor types in a DataSet, They are bulk loaded, while Recordset work with cursors and they are loaded on demand.

§ DataSets have no current record pointer, you can use For Each loops to move through the data. Recordsets have pointers to move through them.

§ You can store many edits in a DataSet, and write them to the original data source in a single operation. Recordset can have a single edit at a time.

§ Dataset can fetch source data from many tables at a time, for Recordset you can achieve the same only using the SQL joins.

4. What is the difference between an abstract method & virtual method?
Answer: 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 the 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.

5. What are the different types of assemblies? Explain.
Answer: Assemblies can be static or dynamic. Static assemblies can include .NET Framework types (interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and so on). Static assemblies are stored on disk in portable executable (PE) files. You can also use the .NET Framework to create dynamic assemblies, which are run directly from memory and are not saved to disk before execution. You can save dynamic assemblies to disk after they have executed.

6. What are the difference between Structure and Class?
Answer:

§ 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.

7. What are the difference between const and readonly?
Answer:

§ A const can not be static, while readonly can be static.

§ 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.

§ A const’s value is evaluated at design time, while a readonly’s value is evaluated at runtime.

8. Differences between dataset.clone and dataset.copy
Answer: dataset.clone copies just the structure of dataset (including all the datatables, schemas, relations and constraints.), However it doesn’t copy the data. On the other hand dataset.copy, copies both the dataset structure and the data.

9. Describe the difference between inline and code behind.
Answer: Inline code written along with the html and design blocks in an .aspx page. Code-behind is code written in a separate file (.cs or .vb ) and referenced by the .aspx page.

10. What is Difference between Namespace and Assembly?
Answer: Namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

11. What is the difference between early binding and late binding?
Answer: Calling a non-virtual method, decided at a compile time is known as early binding. Calling a virtual method (Pure Polymorphism), decided at a runtime is known as late binding.

12. What is the difference between User Control and Custom Control?
Answer: 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.

13. What is the difference between ASP Session State and ASP.Net Session State?
Answer: ASP session state relies on cookies, Serialize all requests from a client, does not survive process shutdown, Can not maintained across machines in a Web farm.

14. What is the difference bettween DataReader and DataSet?
Answer: DataReader represents only one database record at a time. You must call the Read() method to fetch each new record from the underlying database table into memory. Each time you call Read() again, the previously fetched record is lost. DataSet is on the other hand, enables you to represent the results of a database query in your server’s memory. Because a DataSet provides you with a memory-resident representation of data, you can work with the results of a database query as a whole. DataReader must remain connected to a database table. A DataReader is tied down to its underlying data source. The DataSet object is central to supporting disconnected, and distributed data scenarios with ADO.NET. The DataSet is a memory-resident representation of data that provides a consistent relational programming model regardless of the data source. It might be helpful to think of a DataReader as a forward-only recordset. A DataSet, on the other hand, is similar to a disconnected, client-side, static recordset. DataSets also require more overhead to create and populate than DataReaders.

  • Abbreviations

1. CLR = Common Language Runtime

2. CLS = Common Language Specifications

3. CTS = Common Type Specifications

4. GC = Garbage Collector.

5. WSDL = Web Services Description Language.

6. MSIL = Microsoft Intermediate Language.

7. CIL = Common Intermediate Language - MSIL.

8. JIT = Just In Time.

9. PE = Portable Executable – A file format.

10. COFF = Common Object File Format – A file format.

11. GAC = Global Assembly Cache.

12. DDL = Data Definition Language.

13. DML = Data Manipulation Language.

14. CAS = Code Access Security.

15. RCW = Runtime Callable Wrapper.

16. COM = Component Object Model.

17. CCW = COM Callable Wrapper.

18. DOM = Document Object Model.

19. DNA = Distributed interNet Applications Architecture.

20. GUID = Globally Unique Identifier.

21. MS-DTC = Microsoft Distributed Transaction Coordinator.

22. OLTP = Online Transaction Processing.

23. OLAP = Online Analytical Processing.

24. RAD = Rapid Application Development.

25. SMTP = Simple Mail Transfer Protocol.

26. SOAP = Simple Object Access Protocol.

27. TCP = Transport Control Protocol.

28. TLB = Type Library.

29. UDF = Uniform Data Format.

30. UDDI = Universal Description, Discovery and Integration.

  • True/False

1. A Web service can only be written in .NET?
Answer: False (Java also)

2. To test a Web service you must create a windows application or Web application to consume this service?
Answer: False, the webservice comes with a test page and it provides HTTP-GET method to test it.

  • Simple Questions

1. What is IL? (What is MSIL or CIL, What is JIT?)
MSIL is the CPU –independent instruction set into which .Net framework programs are compiled. It contains instructions for loading, storing initializing, and calling methods on objects.

2. What is CLR?
Answer: CLR also known as Common Language Run time provides a environment in which program are executed, it activate object, perform security check on them, lay them out in the memory, execute them and garbage collect them.

3. What is CTS?
Answer: The common type system is a rich type system, built into the common language runtime, which supports the types and operations found in most programming languages.

4. What is CLS?
Answer: CLS also known as Common Language Specification defines the rules which all language must support, in order to be a part of .Net framework. The Common Language Specification is a set of constructs and constraints that serves as a guide for library writers and compiler writers. It allows libraries to be fully usable from any language supporting the CLS, and for those languages to integrate with each other. The Common Language Specification is a subset of the common type system. The Common Language Specification is also important to application developers who are writing code that will be used by other developers.

5. Which class does the web page belong to in ASP.Net?
Answer: System.Web.UI.Page

6. Which class deals wit the user’s locale information?
Answer: System.Web.UI.Page.Culture

7. What data type does the RangeValidator control support?
Answer: Integer, Date and String.

8. What is the difference between Server.Transfer and Response.Redirect?
Answer: Server.Transfer, transfers the control of a web page, posting a form data, while Response.Redirect simply redirects a page to another page, it can not post a form data to another page. Server.Transfer is more efficient over the Response.Redirect, because Response.Redirect causes a round trip to server as the page is processed once again on the client and a request is made to server there after.

9. Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?
Answer: All the global declarations or the variables used commonly across the application can be deployed under Application_Start. All the user specific tasks or declarations can be dealt in the Session_Start subroutine.

10. What is viewState?
Answer: ViewState is a .Net mechanism to store the posted data among post backs. ViewState allows the state of objects to be stored in a hidden field on the page, saved on client side and transported back to server whenever required.

11. What is the lifespan for items stored in ViewState?
Answer: Items stored in a ViewState exist for the life of the current page, including the post backs on the same page.

12. Can we disable ViewState, If, yes how?
Answer: ViewState can be disabled by using “EnableViewState” property set to false.

13. What’s a bubbled event?
Answer: When a complex control like datalist or datagrid, which contains a child control, using an itemcommand can listen to the events raised by the child control in the main control. The process of listening to the child control in the main or parent control is called as event bubbling.

14. What is an assembly?
Answer: Assemblies are the building blocks of the .NET framework. They are the logical grouping of the functionality in a physical file.

15. What are different types of Assemblies?
Answer: Single file and multi file assembly. Assemblies can be static or dynamic. Private assemblies and shared assemblies

16. Which method do you invoke on the DataAdapter control to load your generated dataset with data?
Answer: DataAdapter’s fill () method is used to fill load the data in dataset.

17. Can you edit data in the Repeater control?
Answer: No, it just reads the information from its data source

18. Which template is to be provided in the Repeater control in order to display a data? Which template will display every other row in another color?
Answer: ItemTemplate, AlternatingItemTemplate

19. What are the most important property and most important method of a Repeater control?
Answer: The DataSource property and DataBind() method.

20. How many classes can a single .NET DLL contain?
Answer: It can contain many classes.

21. What are the advantages of an assembly?
Answer: Increased performance. Better code management and encapsulation. It also introduces the n-tier concepts and business logic.

22. What is the purpose of an Assembly?
Answer: An assembly controls many aspects of an application. The assembly handles versioning, type and class scope, security permissions, as well as other metadata including references to other assemblies and resources. The rules described in an assembly are enforced at runtime

23. What a static assembly consist of in general?
Answer: In general, a static assembly consist of the following four elements:

§ Assembly Manifest, which contains the assembly metadata.

§ Type Metadata.

§ MSIL code that implements the types.

§ A set of resources.

From above all only the manifest is required, however the other types and resources add the additional functionality to the assembly.

24. What is GAC or Global Assembly Cache?
Answer: Global Assembly Cache (GAC) is a common place to share the .NET assemblies across many applications. GAC caches all strong named assembly references within it. All System assemblies that come with the .NET framework reside in the GAC.

25. How to view an assembly?
Answer: We can use the tool “ildasm.exe” known as “Assembly Disassembler” to view the assembly.

26. What is Authentication and Authorization?
Answer: Authentication is the process of identifying users. Authentication is identifying/validating the user against the credentials (username and password) and 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.

27. What are the types of Authentication? Describe.
Answer: There are 3 types of Authentication. Windows, Forms and Passport Authentication.

§ Windows authentication uses the security features integrated into the Windows NT and Windows XP operating systems to authenticate and authorize Web application users.

§ Forms authentication allows you to create your own list/database of users and validate the identity of those users when they visit your Web site.

§ Passport authentication uses the Microsoft centralized authentication provider to identify users. Passport provides a way to for users to use a single identity across multiple Web applications. To use Passport authentication in your Web application, you must install the Passport SDK.

28. What are the types of comment in C#?
Answer: There are 3 types of comments in C#.
Single line (//), Multi line (/* */)and Page Comments (///).

29. What is an ArrayList?
Answer: The ArrayList object is a collection of items containing a single data value.

30. What is a HashTable?
Answer: The Hashtable object contains items in key/value pairs. The keys are used as indexes, and very quick searches can be made for values by searching through their keys.

31. What is SortedList?
Answer: The SortedList object contains items in key/value pairs. A SortedList object automatically sorts items in alphabetic or numeric order.

32. What is a Literal Control?
Answer: The Literal control is used to display text on a page. The text is programmable. This control does not let you apply styles to its content!

33. What is CAS or Code Access Security?
Answer: CAS is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running. For example, it is CAS that will prevent a .NET web applet from formatting a hard disk.

34. What is Side-by-Side Execution
Answer: The CLR allows any versions of the same-shared DLL (shared assembly) to execute at the same time, on the same system, and even in the same process. This concept is known as side-by-side execution.

35. What are the different types of Caching?
Answer: 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.

36. What are the different types of Validation Controls?
Answer: There are six types of validation controls available:

§ RequiredFieldValidator

§ RangeValidator

§ RegularExpressionValidator

§ CompareValidator

§ CustomValidator

§ ValidationSummary

37. How to Manage State in ASP.Net?
There are several ways to manage a state.

§ ViewState

§ QueryString

§ Cookies

§ Session

§ Application

38. What base class all Web Forms inherit from?
Answer: System.Web.UI.Page.

39. What method do you use to explicitly kill a user’s Session?
Answer: HttpContext.Current.Session.Abandon().

40. What are the layouts of ASP.NET Pages?
Answer: GridLayout and FlowLayout. GridLayout positions the form object on absolute x and y co-ordinates of the screen. FlowLayout positions the form objects relative to each other.

41. What is the Web User Control?
Answer: Combines existing Server and HTML controls by using VS.Net. to create functional units that encapsulate some aspects of UI. Resides in Content Files, which must be included in project in which the controls are used.

42. What is the Composite Custom Control?
Answer: combination of existing HTML and Server Controls.

Tricky Questions

1. If I’m developing an application that must accommodate multiple security levels though secure login and my 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?
Answer: You can use the security state maintained using a database. (Use Authentication mode as database)

2. What’s the difference between Codebehind=”MyCode.aspx.cs” and src=”MyCode.aspx.cs” mce_src=”MyCode.aspx.cs”?
Answer: Visual Studio uses the Codebehind attribute to distinguish the page source or programming logic from the design. Also the src attribute will make the page compile on every request. That is the page will not be compiled in advance and stored in the bin as a dll instead it will be compiled at run time.

3. Suppose you want a certain ASP.NET function executed on MouseOver over a certain button or textbox. Where do you add an event handler?
Answer: Every web control has a ability to add the attributes on client side which will execute on client side and run a client side script like a javascript function.
btnSubmit.Attributes.Add(“onMouseOver”,”someClientCode();”) //For on mouse over of a button
TextBox1.Attributes.Add(“onFocus”,“ClearText();”) //For on focus of a text box

4. Explain what a diffgram is and a good use for one?
Answer: The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. For reading database data to an XML file to be sent to a Web Service.

5. What base class do all Web Forms inherit from?
Answer: The Page class.

6. Name two properties common in every validation control?
Answer: ControlToValidate and Text property.

7. What tags do you need to add within the Datagrid tags to bind columns manually?
Answer: Set AutoGenerateColumns Property to false on the Datagrid tag

8. What tag do you use to add a hyperlink column to the DataGrid?
Answer: asp:HyperLinkColumn

9. What is the transport protocol you use to call a Web service?
Answer: SOAP (Simple Object Access Protocol) is the preferred protocol.

10. Where on the Internet would you look for Web services?
Answer: http://www.uddi.org

11. Which control would you use if you needed to make sure the values in two different controls matched?
Answer: CompareValidator Control

12. What are the assembly entry points? An Assembly can have how many entry points at a time?
Answer: An assembly can have only one entry point from DllMain, WinMain or Main.

13. What does an assembly contain?
Answer:
• Manifest - The metadata describing the information below.
• Assembly name - Aids in versioning and visibility scope.
• Version information - The version number is integrated into the assembly’s identity.
• Types - Boundaries and scopes of methods, classes, properties, events, attributes.
• Locale - Information describing language/culture.
• Cryptographic Hash - Public key encoded hash acting as version/security check.
• Security Permissions - The permissions within the assembly determine the permissions that can be granted for all aspects of the assembly contents.

14. What does an assembly manifest contains?
Answer: It contains assembly name, version number (major.minor.build.revision) and culture Information. It also specifies the strong name information, which is useful for shared assemblies, and list of files, an assembly contains. It also provides information for type references in an assembly and other referenced assemblies.

15. Which tool is used to deploy an assembly, so as the assembly is available to all the application?
Answer: The GacUtil.exe is the tool, which allows us to add any assembly to the windows GAC.

16. How many catch statements can be associated with single try statement?
Answer: There can be a zero or more catch statement for each try statement. So it has not limit to the number of catch statement per try statement.

17. What is Console and System a Class/a Data Member/a routine/a namespace or a type?
Answer: Console is a class and System is namespace.

18. How many values can be returned from a method in C#?
Answer: Only one value can be returned from method, however you can use ref or out variable to change more than one value in called method.

19. How to declare a variable named this in C#, with data type string?
Answer: string @this;

20. Can we change the dimension of Array at run time like Array [3, 4]?
Answer: Yes, We can change only the first position of array dimension.

21. What keyword is used to accept a variable number of parameter in a method?
Answer: “params” keyword is used as to accept variable number of parameters.

22. What is a Namespace? What is the use of a namespace?
Answer: Namespaces are logical grouping of classes and other types in hierarchical structure. Namespaces are useful to avoid collision or ambiguity among the classes and type names. Another use of the namespace is to arrange a group of classes for a specific purpose.

23. What does a keyword using works for?
Answer: Using is just a convention or a short-cut method which allows us to access the classes in a namespace by referencing it once. So when ever we want use the classes or methods in them, we can avoid typing the entire namespace hierarchy. However it is not a good practice when there are likely chances to have name ambiguity or collision of class names.

24. What is Enums in C#?
Answer: Enums or Enumerators are used to declare a set of related constants (default start with 0); they are only available with primitive data types like int and short etc.

25. What is Delegates?
Answer: 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. Delegates are generally used as basis of events, which allow any delegate to easily be registered for as event.

26. Which are the namespaces that are imported automatically by Visual Studio in ASP.Net?
Answer: There are 7 namespaces which are imported automatically.

§ System

§ System.Collections

§ System.IO

§ System.web

§ System.web.UI

§ System.web.UI.HTMLControls

§ System.web.UI.WebControls

27. Which namespaces are used for data access?

§ System.Data

§ System.Data.OleDB

§ System.Data.SQLClient

28. What do you mean by boxing and un-boxing?
Answer: C# provides us with Value types and Reference Types. Value Types are stored on the stack and Reference types are stored on the heap. The conversion of value type to reference type is known as boxing and converting reference type back to the value type is known as un-boxing.
e.g.
int x = 10;
object o = x ; // Implicit boxing
object o = (object) x; // Explicit Boxing
x = o; // Implicit Un-Boxing
x = (int)o; // Explicit Un-Boxing

29. What are the different methods available under sqlcommand class to access the data?

§ ExecuteReader –Used where one or more records are returned – SELECT Query.

§ ExecuteNonQuery – Used where it affects a state of the table and no data is being queried - INSERT, UPDATE, DELETE, CREATE and SET queries.

§ ExecuteScalar – Used where it returns a single record(a single value normally) – SQL Functions like MIN(), NAX()

30. What are the different types of Session state management options available with ASP.NET?
Answer: ASP.NET provides In-Process & Out-of-Process state management,
Also known as “In-Proc” and “Out-Proc”. In-Proc stores the session in memory of the web server, that is on the same server the ASP.Net page is.
On the other hand Out-Proc session state management stores the session data on external data source, which can be a SQL Server or Server State Service. Out-of-Process state management requires the objects stored in session, must be serializable.

31. What is Remoting? Give Example.
Answer: Remoting is a means by which one operating system process, or program, can communicate with another process. The two processes can exist on the same computer or on two computers connected by a LAN or the Internet. Web services are probably the best known type of remoting, but they are not the only option.

32. What is Marshalling?
Answer: Marshaling is a process of making an object in one process (the server) available to another process (the client). There are two ways to achieve the marshalling.

i. Marshal by value: the server creates a copy of the object passes the copy to the client. When a client makes a call to an object marshaled by value (MBV), the server creates an exact copy and sends that copy to the client. The client can then use the object’s data and executable functionality directly within its own process or application domain without making additional calls to the server. Objects that the application accesses frequently are best remoted using MBV.

ii. Marshal by reference: the client creates a proxy for the object and then uses the proxy to access the object. When a client makes a call to an object marshaled by reference (MBR), the .NET framework creates a proxy in the client’s application domain and the client uses that proxy to access the original object on the server. Large objects that the application accesses relatively infrequently are good candidates for MBR.

33. What is a Static class? What are its features?
Answer: Static class is a class which can be used or accessed without creating an instance of the class.
Important Features:

i. Static class only contains static members and a private constructor.

ii. Static class cannot be instantiated.

iii. Static classes are sealed by default and therefore cannot be inherited.

34. What is sealed class? What are its features?
Answer: Sealed classes are those classes which can not be inherited and thus any sealed class member can not be derived in any other class. A sealed class cannot also be an abstract class.
In C# structs are implicitly sealed; therefore, they cannot be inherited.

35. Can we declare a method as sealed?
Answer: 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.
E.g.
using System;
class MyClass1
{
public int x;
public int y;
public virtual void Method() {
Console.WriteLine(”virtual method”); }
}
class MyClass : MyClass1
{
public override sealed void Method() {
Console.WriteLine(”sealed method”); }
}
class MainClass
{ public static void Main() {
MyClass1 mC = new MyClass();
mC.x = 110;
mC.y = 150;
Console.WriteLine(”x = {0}, y = {1}”, mC.x, mC.y);
mC.Method(); }
}

36. What is a DataSet ?
Answer: A DataSet is an in memory representation of data loaded from any data source.

37. What is a DataTable?
Answer: A DataTable is a class in .NET Framework and in simple words a DataTable object represents a table from a database.

38. If you want to view an Assembly how to you go about it? What is ILDASM?
Answer: You can use the MSIL Disassembler (Ildasm.exe) to view Microsoft intermediate language (MSIL) information in a file. If the file being examined is an assembly, this information can include the assembly’s attributes, as well as references to other modules and assemblies. This information can be helpful in determining whether a file is an assembly or part of an assembly, and whether the file has references to other modules or assemblies.

39. Where is version information stored of an assembly?
Answer: The version number is stored in the assembly manifest along with other identity information, including the assembly name and public key, as well as information on relationships and identities of other assemblies connected with the application.

40. Is versioning applicable to private assemblies?
Answer: No

41. How to create a shared assembly or add an assembly to GAC?
Answer: There are several ways an assembly can be added to GAC.

i. Use .msi installer designed to work with the global assembly cache.

ii. Use GACUtil.exe provided by the .NET Framework SDK.

iii. Use Windows Explorer to drag assemblies into the cache.

42. What is strong Name?
Answer:

43. What is reflection?
Answer: All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly. Reflection is ability to find information about types contained in an assembly at run time.

44. How can I produce an assembly?
Answer: Simply compile your class/module with the following command.
C#.Net - CSC /t:library yourclassname.cs
VB.Net - VBC /t:library yourmodulename.vb

45. What is an Application Domain? How they get created?
Answer: An Application Domain can be thought of as a lightweight processes controlled by the .Net runtime. Application Domains are usually created by hosts like Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new Application Domain for every application.

46. Do I have any control over the garbage collection algorithm?
Answer: Yes, we have a limited control over the GC algorithm, For example, the System.GC class exposes a Collect method - this forces the garbage collector to collect all unreferenced objects immediately.

47. What is a life span of a static variable?
Answer: A static variable’s life span is till the class is in memory.

48. What is a Page Life Cycle of an ASP.Net page?
Answer: There are various stages described as under.

§ Init

§ LoadViewState

§ LoadPostBackData

§ Load

§ RaisePostBackDataChangedEvent

§ RaisePostBackEvents

§ Pre-Render

§ SaveViewState

§ Render

§ Unload

49. Can the action attribute of a server-side <form>tag be set to a value and if not how can you possibly pass data from a form to a subsequent Page?
Answer: No, Assigning value will not work because will be overwritten at the time of rendering. We can assign value to it by register a startup script which will set the action value of form on client-side. On other hand we can use Server.Transfer or Response.Redirect.

50. How do you turn off cookies in one page of your asp.net application?
Answer: We may not use them at the max, However to allow the cookies or not, is client side functionality.

51. Which method do you use to redirect to user to another page without performing a round trip to Client?
Answer: Server.Transfer(“AnotherPage.aspx”).

52. How many namespaces are in .NET version 1.1?
Answer: 124.

53. Should Validation occur on Client/Server Side for Date Input?
Answer: Both. Client-side reduces extra round-trip. Server-Side ensures prevention against hacking and failure against automated requests.

54. What are the web form events?
Answer:

i. The first event that occurs in the life of a Web Form is the Init event. This is raised so that we can have initialization code for the page. The controls on the page are not yet created at this point. This event is raised once for each user of the page.

ii. The Load event follows the Init event. Subsequently, it is raised each time the page is requested. When this event is raised, all child controls of the Web Form are loaded and accessible. You should be able to retrieve data and populate the controls so that they can render themselves on the page when sent back to the client.

iii. The PreRender event happens just before the page is rendered and sent back to the client. We don’t often handle this event; however, it depends on the situation.

iv. The last event in the life of a Web Form is the Unload event. This happens when the page is unloaded from memory. Final cleanup should be done here.

  • OOPS

1. What is a class?
Answer: Class is concrete representation of an entity. It represents a group of objects, which hold similar attributes and behavior. It provides Abstraction and Encapsulations.

2. What is an Object? What is Object Oriented Programming?
Answer: Object represents/resembles a Physical/real entity. An object is simply something you can give a name. Object Oriented Programming is a Style of programming that represents a program as a system of objects and enables code-reuse.

3. What is Encapsulation?
Encapsulation is binding of attributes and behaviors. Hiding the actual implementation and exposing the functionality of any object. Encapsulation is the first step towards OOPS, is the procedure of covering up of data and functions into a single unit (called class). Its main aim is to protect the data from out side world.

4. What is Abstraction?
Answer: Hiding the complexity. It is a process of defining communication interface for the functionality and hiding rest of the things.

5. What is Overloading?
Answer: Adding a new method with the same name in same/derived class but with different number/types of parameters. It implements Polymorphism.

6. What is Overriding?
Answer: A process of creating different implementation of a method having a same name as base class, in a derived class. It implements Inheritance.

7. What is Shadowing?
Answer: When the method is defined as Final/sealed in base class and not override able and we need to provide different implementation for the same. This process is known as shadowing, uses shadows/new keyword.

8. What is Inheritance?
Answer: It is a process of acquiring attributes and behaviors from another object (normally a class or interface).

9. What is an Abstract class?
Answer: An abstract class is a special kind of class that cannot be instantiated. It normally contains one or more abstract methods or abstract properties. It provides body to a class.

10. What is an Interface?
Answer: An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body.

11. What is Polymorphism?
Answer: Mean by more than one form. Ability to provide different implementation based on different number/type of parameters.

12. What is Pure-Polymorphism?
Answer: When a method is declared as abstract/virtual method in a base class and which is overridden in a base class. If we create a variable of a type of a base class and assign an object of a derived class to it, it will be decided at a run time, which implementation of a method is to be called.
This is known as Pure-Polymorphism or Late-Binding.

13. What is a Constructor?
Answer: A special Method Always called whenever an instance of the class is created.

14. What is a Destructor?
Answer: A special method called by GC. just before object is being reclaimed by GC.

15. How a base class method is hidden?
Answer: Hiding a base class method by declaring a method in derived class with keyword new. This will override the base class method and old method will be suppressed.

16. What Command is used to implement properties in C#?
Answer: get & set access modifiers are used to implement properties in c#.

17. What is method overloading?
Answer: Method overloading is having methods with same name but carrying different signature, this is useful when you want a method to behave differently depending upon a data passed to it.

18. Can constructors have parameters?

19. What are Static Assembly and Dynamic Assembly?
Answer: Static assemblies can include .NET Framework types (interfaces and classes) as well as resources for the assembly (bitmaps, JPEG files, resource files, and so forth). Static assemblies are stored on disk. Dynamic assemblies run directly from memory and are not saved to disk before execution.

20. Describe the functionality of an assembly.
Answer: It is the smallest unit that has version control. All types and resources in the same assembly are versioned as a unit and support side by side execution. Assemblies contain the metadata and other identities which allow the common language runtime to execute. They are the boundaries providing the type check. They the unit where security permissions are requested and granted.

21. What is serialization?
Answer: 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 (e.g. during remoting), or to persist objects (e.g. to a file or database). There are two separate mechanisms provided by the .NET class library for serialization - XmlSerializer and SoapFormatter and BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses SoapFormatter/BinaryFormatter for remoting.

  • SQL: Queries

1. Write a query to select the second highest salary from a table.
Answer: SELECT max(salary) AS salary2 FROM orders WHERE salary < (SELECT max(salary) AS salary1 FROM orders)

2. Write a query to select the 5th highest salary from a table.
Answer: SELECT min(salary) AS high5 FROM employee WHERE salary IN(SELECT DISTINCT TOP 5 salary FROM orders ORDER BY salary DESC)

3. How to find duplicate records with the number they are duplicated?
Answer: SELECT Id, count (*) as number_records from table group by id having count (*) > 1.

  • SQL: Questions

1. What is the difference between Delete and Truncate command in SQL?
Answer: Delete command and truncate command both will delete the data, however the truncate command can not be rolled back as delete can be. The delete command can be used for selected records using the where clause but with the truncate command we have to loose data. DELETE statement is a logged operation and hence takes more time then truncate.

2. What is Magic Table in SQL?
Answer: The insert and Delete commands are known as magic tables in SQL.

3. Can Primary key is a Foreign Key on the same table?
Answer: Yes, Consider a category table in a e-commerce web site.
Category_Id, Category_Name, Parent_Category_ID. In this table all the parent categories are also categories. When we create a self join category id will be treated as foreign key to the same table.

4. What is Normalization? What are it’s rules?
Answer: Normalisation is the technique in the database design wher ethe idea is to reduce the redundancy of non key data items across the table.

§ Rule 1: There should be a one-to-one relationship between the instances of an entity and the rows of the table.

§ Rule 2: A field should have the same meaning in each row of the table.

§ Rule 3: Each table should represent at most one entity.

§ Rule 4: Multiple instances of an entity should be represented by multiple rows in a table.

§ Rule 5: Joins should be based only on primary and foreign-key equality.

§ Rule 6: Make sure keys are linked correctly.

5. What are the advantages and disadvantages of Normalization?
Answer: There are several advantages of normalization as under:

§ Faster sorting and index creation.

§ A larger number of clustered indexes.

§ Narrower and more compact indexes.

§ Fewer indexes per table, which improves the performance of INSERT, UPDATE, and DELETE statements

§ Fewer null values and less opportunity for inconsistency, which increase database compactness.
Beside the above benefits there are few disadvantages as well:

§ Increased amount of Normalization increases the amount of complexity of joins between tables and that hinders the performance.

6. What are the conditions to achieve the normalization?
Answer: There are few conditions to achieve the normalization:

§ There should be a unique row identifier.

§ A table should store only data for a single type of entity. For e.g. details for book’s publisher and book’s author should be saved under different table.

§ A table should avoid columns which can be null-able.

§ A table should avoid duplication of data and columns.

7. What is a Stored Procedure? State its advantage.
Answer: A stored procedure is a set of pre-compiled SQL commands (query statements), which are stored in the server. It is faster then the loose SQL statements processed on client, as it is pre-compiled. It can execute more then one SQL commands once as they are bundled in a single entity. We can use control statements within the stored procedure, which will allow us to repeat some SQL command. It can send return values depending upon the result. Stored procedures are used to reduce network traffic.

8. What is a Trigger?
Answer: Triggers are a special type of stored procedure, which gets invoked upon a certain event. They can be performed upon an INSERT, UPDATE and DELETE.

9. What is a Clustered Index?
Answer: The data rows are stored in order based on the clustered index key. Data stored is in a sequence of the index. In a clustered index, the physical order of the rows in the table is the same as the logical (indexed) order of the key values. A table can contain only one clustered index. A clustered index usually provides faster access to data than does a non-clustered index

10. What is a Non-Clustered Index?
Answer: The data rows are not stored in any particular order, and there is no particular order to the sequence of the data pages. In a non-clustered index, the physical order of the rows in the table is not same as the logical (indexed) order of the key values.

11. Describe the three levels of data abstraction?
The are three levels of abstraction:

§ Physical level: The lowest level of abstraction describes how data are stored.

§ Logical level: The next higher level of abstraction, describes what data are stored in database and what relationship among those data.

§ View level: The highest level of abstraction describes only part of entire database.

12. What is DDL (Data Definition Language)?
Answer: A data base schema which is specified by a set of definitions expressed by a special language is called DDL. Data Definition Language (DDL) is used to define and manage all the objects in an SQL database.

13. What is DML?
Answer: It is a special language used to manipulate the Data. Data Manipulation Language (DML), which is used to select, insert, update, and delete data in the objects defined using DDL.

14. What is a PRIMARY KEY?
Answer: The PRIMARY KEY is the column(s) used to uniquely identify each row of a table.

15. What is a FOREIGN KEY?
Answer: A FOREIGN KEY is one or more columns whose values are based on the PRIMARY or CANDITATE KEY values from the database.

16. What is a UNIQUE KEY?
Answer: A UNIQUE KEY is one or more columns that must be unique for each row of the table.

17. What is the difference between UNIQUE and PRIMARY KEY?
Answer: The UNIQUE KEY column restricts entry of duplicate values but entry of NULL value is allowed. In case of PRIMARY KEY columns entry of duplicate as well as <NULL> value is also restricted.

18. What is a VIEW?
Answer: A View is a database object that is a logical representation of a table. It is derived from a table but has no storage space of its own and often may be used in the same manner as a table.

19. What is a ROWID?
Answer: ROWID is the logical address of a row, and it is unique within the database.

20. What is INDEX?
Answer: INDEX is a general term for an SQL feature used primarily to speed up execution and impose UNIQUENESS upon data. You can use an index to gain fast access to specific information in a database table. An index is a structure that orders the values of one or more columns in a database table. The index provides pointers to the data values stored in specified columns of the table, and then orders those pointers according to the sort order you specify.

21. What is a cursor?
Answer: An entity that maps over a result set and establishes a position on a single row within the result set. After the cursor is positioned on a row, operations can be performed on that row, or on a block of rows starting at that position. The most common operation is to fetch (retrieve) the current row or block of rows.

22. The Difference between ‘Count’ and ‘Count (*)’?
Answer: ‘Count’: Counts the number of non-null values. ‘Count (*)’: Counts the number of rows in the table, including null values and duplicates.

 

 

This is a list of questions I have gathered and created over a period of time from my experience, many of which I felt where incomplete or simply wrong.  I have finally taken the time to go through each question and correct them to the best of my ability.  However, please feel free to post feedback to challenge, improve, or suggest new questions.  I want to thank those of you that have contributed quality questions and corrections thus far.

There are some questions in this list that I do not consider to be good questions for an interview.  However, they do exist on other lists available on the Internet so I felt compelled to keep them here for easy access.

 

 

 

  1. Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
    inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.
     
  2. What’s the difference between Response.Write() andResponse.Output.Write()?
    Response.Output.Write() allows you to write formatted output. 
     
  3. What methods are fired during the page load?
    Init() - when the page is instantiated
    Load() - when the page is loaded into server memory
    PreRender() - the brief moment before the page is displayed to the user as HTML
    Unload() - when page finishes loading. 
     
  4. When during the page processing cycle is ViewState available?
    After the Init() and before the Page_Load(), or OnLoad() for a control. 
     
  5. What namespace does the Web page belong in the .NET Framework class hierarchy?
    System.Web.UI.Page 
     
  6. Where do you store the information about the user’s locale?
    System.Web.UI.Page.Culture 
     
  7. What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?
    CodeBehind is relevant to Visual Studio.NET only. 
     
  8. What’s a bubbled event?
    When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents. 
     
  9. Suppose you want a certain ASP.NET function executed on MouseOver for a certain button.  Where do you add an event handler?
    Add an OnMouseOver attribute to the button.  Example: btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();"); 
     
  10. What data types do the RangeValidator control support?
    Integer, String, and Date. 
     
  11. Explain the differences between Server-side and Client-side code?
    Server-side code executes on the server.  Client-side code executes in the client's browser. 
     
  12. What type of code (server or client) is found in a Code-Behind class?
    The answer is server-side code since code-behind is executed on the server.  However, during the code-behind's execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser.  But just to be clear, code-behind executes on the server, thus making it server-side code. 
     
  13. Should user input data validation occur server-side or client-side?  Why?
    All user input data validation should occur on the server at a minimum.  Additionally, client-side validation can be performed where deemed appropriate and feasable to provide a richer, more responsive experience for the user. 
     
  14. What is the difference between Server.Transfer and Response.Redirect?  Why would I choose one over the other?
    Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser.  This provides a faster response with a little less overhead on the server.  Server.Transfer does not update the clients url history list or current url.  Response.Redirect is used to redirect the user's browser to another page or site.  This performas a trip back to the client where the client's browser is redirected to the new page.  The user's browser history list is updated to reflect the new address. 
     
  15. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
    Valid answers are:
    ·  A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
    ·  A DataSet is designed to work without any continuing connection to the original data source.
    ·  Data in a DataSet is bulk-loaded, rather than being loaded on demand.
    ·  There's no concept of cursor types in a DataSet.
    ·  DataSets have no current record pointer You can use For Each loops to move through the data.
    ·  You can store many edits in a DataSet, and write them to the original data source in a single operation.
    ·  Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources. 
     
  16. What is the Global.asax used for?
    The Global.asax (including the Global.asax.cs file) is used to implement application and session level events. 
     
  17. What are the Application_Start and Session_Start subroutines used for?
    This is where you can set the specific variables for the Application and Session objects. 
     
  18. Can you explain what inheritance is and an example of when you might use it?
    When you want to inherit (use the functionality of) another class.  Example: With a base class named Employee, a Manager class could be derived from the Employee base class. 
     
  19. Whats an assembly?
    Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN 
     
  20. Describe the difference between inline and code behind.
    Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page. 
     
  21. Explain what a diffgram is, and a good use for one?
    The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML.  A good use is reading database data to an XML file to be sent to a Web Service. 
     
  22. Whats MSIL, and why should my developers need an appreciation of it if at all?
    MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL.  MSIL also allows the .NET Framework to JIT compile the assembly on the installed computer. 
     
  23. Which method do you invoke on the DataAdapter control to load your generated dataset with data?
    The Fill() method. 
     
  24. Can you edit data in the Repeater control?
    No, it just reads the information from its data source. 
     
  25. Which template must you provide, in order to display data in a Repeater control?
    ItemTemplate. 
     
  26. How can you provide an alternating color scheme in a Repeater control?
    Use the AlternatingItemTemplate. 
     
  27. What property must you set, and what method must you call in your code, in order to bind the data from a data source to the Repeater control?
    You must set the DataSource property and call the DataBind method. 
     
  28. What base class do all Web Forms inherit from?
    The Page class. 
     
  29. Name two properties common in every validation control?
    ControlToValidate property and Text property. 
     
  30. Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?
    DataTextField property. 
     
  31. Which control would you use if you needed to make sure the values in two different controls matched?
    CompareValidator control. 
     
  32. How many classes can a single .NET DLL contain?
    It can contain many classes.
     

Web Service Questions

  1. What is the transport protocol you use to call a Web service?
    SOAP (Simple Object Access Protocol) is the preferred protocol. 
     
  2. True or False: A Web service can only be written in .NET?
    False 
     
  3. What does WSDL stand for?
    Web Services Description Language. 
     
  4. Where on the Internet would you look for Web services?
    http://www.uddi.org/ 
     
  5. True or False: To test a Web service you must create a Windows application or Web application to consume this service?
    False, the web service comes with a test page and it provides HTTP-GET method to test.
     

State Management Questions

  1. What is ViewState?
    ViewState allows the state of objects (serializable) to be stored in a hidden field on the page.  ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.  ViewState is used the retain the state of server-side objects between postabacks. 
     
  2. What is the lifespan for items stored in ViewState?
    Item stored in ViewState exist for the life of the current page.  This includes postbacks (to the same page). 
     
  3. What does the "EnableViewState" property do?  Why would I want it on or off?
    It allows the page to save the users input on a form across postbacks.  It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser.  When the page is posted back to the server the server control is recreated with the state stored in viewstate. 
     
  4. What are the different types of Session state management options available with ASP.NET?
    ASP.NET provides In-Process and Out-of-Process state management.  In-Process stores the session in memory on the web server.  This requires the a "sticky-server" (or no load-balancing) so that the user is always reconnected to the same web server.  Out-of-Process Session state management stores data in an external data source.  The external data source may be either a SQL Server or a State Server service.  Out-of-Process state management requires that all objects stored in session are serializable.

 

1. What are the main differences between asp and asp.net?

ASP 3.0

• Supports VBScript and JavaScript
o scripting languages are limited in scope
o interpreted from top to bottom each time the page is loaded
• Files end with *.asp extension
• 5 objects: Request, Response, Server, Application, Session
• Queried databases return recordsets
• Uses conventional HTML forms for data collection

ASP .NET

• Supports a number of languages including Visual Basic, C#, and JScript
o code is compiled into .NET classes and stored to speed up multiple hits on a page
o object oriented and event driven makes coding web pages more like traditional applications
• Files end with *.aspx extension
• .NET contains over 3400 classes
• XML-friendly data sets are used instead of recordsets
• Uses web forms that look like HTML forms to the client, but add much functionality due to server-side coding
• Has built-in validation objects
• Improved debugging feature (great news for programmers)
• ASP .NET controls can be binded to a data source, including XML recordsets
Source: mikekissman.com

2. What is a user control?

• An ASP.NET user control is a group of one or more server controls or static HTML elements that encapsulate a piece of functionality. A user control could simply be an extension of the functionality of an existing server control(s) (such as an image control that can be rotated or a calendar control that stores the date in a text box). Or, it could consist of several elements that work and interact together to get a job done (such as several controls grouped together that gather information about a user's previous work experience).
Source: 15seconds.com

3. What are different types of controls available in ASP.net?
• HTML server controls HTML elements exposed to the server so you can program them. HTML server controls expose an object model that maps very closely to the HTML elements that they render.
• Web server controls Controls with more built-in features than HTML server controls. Web server controls include not only form-type controls such as buttons and text boxes, but also special-purpose controls such as a calendar. Web server controls are more abstract than HTML server controls in that their object model does not necessarily reflect HTML syntax.
• Validation controls Controls that incorporate logic to allow you to test a user's input. You attach a validation control to an input control to test what the user enters for that input control. Validation controls are provided to allow you to check for a required field, to test against a specific value or pattern of characters, to verify that a value lies within a range, and so on.
• User controls Controls that you create as Web Forms pages. You can embed Web Forms user controls in other Web Forms pages, which is an easy way to create menus, toolbars, and other reusable elements.
• Note You can also create output for mobile devices. To do so, you use the same ASP.NET page framework, but you create Mobile Web Forms instead of Web Forms pages and use controls specifically designed for mobile devices.
Source: MSDN

4. What are the validation controls available in ASP.net?

Type of validation Control to use
Description

Required entry RequiredFieldValidator Ensures that the user does not skip an entry.
Comparison to a value CompareValidator Compares a user's entry against a constant value, or against a property value of another control, using a comparison operator (less than, equal, greater than, and so on).
Range checking RangeValidator Checks that a user's entry is between specified lower and upper boundaries. You can check ranges within pairs of numbers, alphabetic characters, and dates.
Pattern matching RegularExpressionValidator Checks that the entry matches a pattern defined by a regular expression. This type of validation allows you to check for predictable sequences of characters, such as those in social security numbers, e-mail addresses, telephone numbers, postal codes, and so on.
User-defined CustomValidator Checks the user's entry using validation logic that you write yourself. This type of validation allows you to check for values derived at run time.
Source: MSDN

5. How will you upload a file to IIS in Asp and how will you do the same in ASP.net?

First of all, we need a HTML server control to allow the user to select the file. This is nothing but the same old <input tag, with the type set to File, such as <input type=file id=”myFile” runat=server />. This will give you the textbox and a browse button. Once you have this, the user can select any file from their computer (or even from a network). Then, in the Server side, we need the following line to save the file to the Web Server.


myFile.PostedFile.SaveAs ("DestinationPath")

Note: The Form should have the following ENC Type
<form enctype="multipart/form-data" runat="server">

Source: ASP Alliance
6. What is Attribute Programming? What are attributes? Where are they used?

Attributes are a mechanism for adding metadata, such as compiler instructions and other data about your data, methods, and classes, to the program itself. Attributes are inserted into the metadata and are visible through ILDasm and other metadata-reading tools. Attributes can be used to identify or use the data at runtime execution using .NET Reflection.
Source: OnDotNet.com

7. What is the difference between Data Reader & Dataset?

Data Reader is connected, read only forward only record set.
Dataset is in memory database that can store multiple tables, relations and constraints; moreover dataset is disconnected and is not aware of the data source.

8. What is the difference between server side and client side code?

Server code is executed on the web server where as the client code is executed on the browser machine.

9. Why would you use “EnableViewState” property? What are the disadvantages?

EnableViewState allows me to retain the values of the controls properties across the requests in the same session. It hampers the performance of the application.

10. What is the difference between Server. Transfer and Response. Redirect?

The Transfer method allows you to transfer from inside one ASP page to another ASP page. All of the state information that has been created for the first (calling) ASP page will be transferred to the second (called) ASP page. This transferred information includes all objects and variables that have been given a value in an Application or Session scope, and all items in the Request collections. For example, the second ASP page will have the same SessionID as the first ASP page.

When the second (called) ASP page completes its tasks, you do not return to the first (calling) ASP page. All these happen on the server side browser is not aware of this.
The redirect message issue HTTP 304 to the browser and causes browser to got the specified page. Hence there is round trip between client and server. Unlike transfer, redirect doesn’t pass context information to the called page.

11. What is the difference between Application_start and Session_start?

Application_start gets fired when an application receive the very first request.
Session_start gets fired for each of the user session.



12. What is inheritance and when would you use inheritance?

The concept of child class inheriting the behavior of the parent is called inheritance.
If there are many classes in an application that have some part of their behavior common among all , inheritance would be used.

13. What is the order of events in a web form?

1. Init
2. Load
3. Cached post back events
4. Prerender
5. Unload

14. Can you edit Data in repeater control?

No

15. Which template you must provide to display data in a repeater control?

Item Template

16. How can you provide an alternating color scheme in a Data Grid?

Use ALTERNATINGITEMSTYLE and ITEMSTYLE, attributes or Templates

17. Is it possible to bind a data to Textbox?

Yes

18. What method I should call to bind data to control?

Bind Data ()

19. How can I kill a user session?

Call session. abandon.

21. Which is the common property among all the validation controls?

ControlToValidate

22. How do you bind a data grid column manually?

Use BoundColumn tag.

23. Web services can only be written in .NET, true or false?

False

24. What does WSDL, UDDI stands for?

Web Service Description Language.
Universal Description Discovery and Integration
25. How can you make a property read only? (C#)

Use key word Read Only

25. Which validation control is used to match values in two controls?

Compare Validation control.

26. To test a Web Service I must create either web application or windows application. True or false?

False

27. How many classes can a single .NET assembly contains?

Any number

28. What are the data types available in JavaScript?

Object is the only data type available.

29. Is it possible to share session information among ASP and ASPX page?

No, it is not possible as both of these are running under different processes.

30. What are the caching techniques available?
Page cahahing.
Fragment Caching
And Data Caching



31. What are the different types of authentication modes available?

1. Window.
2. Form.
3. Passport.
4. None.

32. Explain the steps involved to populate dataset with data?

Open connection
Initialize Adapter passing SQL and connection as parameter
Initialize Dataset
Call Fill method of the adapter passes dataset as the parameter
Close connection.

33. Can I have data from two different sources into a single dataset?

Yes, it is possible.

34. Is it possible load XML into a Data Reader?

No.

35. Is it possible to have tables in the dataset that are not bound to any data source?

Yes, we can create table object in code and add it to the dataset.

36. Why do you deploy an assembly into GAC?

To allow other application to access the shared assembly.

37. How do you uninstall assembly from GAC?

Use Gacutil.exe with U switch.

38. What does Regasm do?

The Assembly Registration tool reads the metadata within an assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently. Once a class is registered, any COM client can use it as though the class were a COM class. The class is registered only once, when the assembly is installed. Instances of classes within the assembly cannot be created from COM until they are actually registered.

39. What is the difference between Execute Scalar and ExceuteNoneQuery?

Execute Scalar returns the value in the first row first column of a query result set.
ExceuteNonQuery return number of rows affected.

40. What is an assembly?

Assembly is a deployment unit of .NET application. In practical terms assembly is an Executable or a class library.

41. What is CLR?

The common language runtime is the execution engine for .NET Framework applications.
It provides a number of services, including the following:
• Code management (loading and execution)
Application memory isolation
• Verification of type safety
• Conversion of IL to native code
• Access to metadata (enhanced type information)
• Managing memory for managed objects
• Enforcement of code access security
• Exception handling, including cross-language exceptions
• Interoperation between managed code, COM objects, and pre-existing DLLs (unmanaged code and data)
• Automation of object layout
• Support for developer services (profiling, debugging, and so on)

42. What is the common type system (CTS)?

The common type system is a rich type system, built into the common language runtime that supports the types and operations found in most programming languages. The common type system supports the complete implementation of a wide range of programming languages.

43. What is the Common Language Specification (CLS)?

The Common Language Specification is a set of constructs and constraints that serves as a guide for library writers and compiler writers. It allows libraries to be fully usable from any language supporting the CLS, and for those languages to integrate with each other. The Common Language Specification is a subset of the common type system. The Common Language Specification is also important to application developers who are writing code that will be used by other developers. When developers design publicly accessible APIs following the rules of the CLS, those APIs are easily used from all other programming languages that target the common language runtime.

44. What is the Microsoft Intermediate Language (MSIL)?

MSIL is the CPU-independent instruction set into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects.
Combined with metadata and the common type system, MSIL allows for true cross-language integration.
Prior to execution, MSIL is converted to machine code. It is not interpreted.

45. What is managed code and managed data?

Managed code is code that is written to target the services of the common language runtime (see what is the Common Language Runtime?). In order to target these services, the code must provide a minimum level of information (metadata) to the runtime. All C#, Visual Basic .NET, and JScript .NET code is managed by default. Visual Studio .NET C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/CLR).
Closely related to managed code is managed data—data that is allocated and de-allocated by the common language runtime's garbage collector. C#, Visual Basic, and JScript .NET data is managed by default. C# data can, however, be marked as unmanaged through the use of special keywords. Visual Studio .NET C++ data is unmanaged by default (even when using the /CLR switch), but when using Managed Extensions for C++, a class can be marked as managed by using the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector. In addition, the class becomes a full participating member of the .NET Framework community, with the benefits and restrictions that brings. An example of a benefit is proper interoperability with classes written in other languages (for example, a managed C++ class can inherit from a Visual Basic class). An example of a restriction is that a managed class can only inherit from one base class.

46. What is an assembly?

An assembly is the primary building block of a .NET Framework application. It is a collection of functionality that is built, versioned, and deployed as a single implementation unit (as one or more files). All managed types and resources are marked either as accessible only within their implementation unit or as accessible by code outside that unit.

Assemblies are self-describing by means of their manifest, which is an integral part of every assembly.



The manifest: Establishes the assembly identity (in the form of a text name), version, culture, and digital signature (if the assembly is to be shared across applications).
Defines what files (by name and file hash) make up the assembly implementation.
Specifies the types and resources that make up the assembly, including which are exported from the assembly.
Itemizes the compile-time dependencies on other assemblies.
Specifies the set of permissions required for the assembly to run properly.

This information is used at run time to resolve references, enforce version binding policy, and validate the integrity of loaded assemblies. The runtime can determine and locate the assembly for any running object, since every type is loaded in the context of an assembly. Assemblies are also the unit at which code access security permissions are applied. The identity evidence for each assembly is considered separately when determining what permissions to grant the code it contains.
The self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment feasible.

47. What are private assemblies and shared assemblies?

A private assembly is used only by a single application, and is stored in that application's install directory (or a subdirectory therein). A shared assembly is one that can be referenced by more than one application. In order to share an assembly, the assembly must be explicitly built for this purpose by giving it a cryptographically strong name (referred to as a strong name). By contrast, a private assembly name need only be unique within the application that uses it.
By making a distinction between private and shared assemblies, we introduce the notion of sharing as an explicit decision. Simply by deploying private assemblies to an application directory, you can guarantee that that application will run only with the bits it was built and deployed with. References to private assemblies will only be resolved locally to the private application directory.
There are several reasons you may elect to build and use shared assemblies, such as the ability to express version policy. The fact that shared assemblies have a cryptographically strong name means that only the author of the assembly has the key to produce a new version of that assembly. Thus, if you make a policy statement that says you want to accept a new version of an assembly, you can have some confidence that version updates will be controlled and verified by the author. Otherwise, you don't have to accept them.
For locally installed applications, a shared assembly is typically explicitly installed into the global assembly cache (a local cache of assemblies maintained by the .NET Framework). Key to the version management features of the .NET Framework is that downloaded code does not affect the execution of locally installed applications. Downloaded code is put in a special download cache and is not globally available on the machine even if some of the downloaded components are built as shared assemblies.
The classes that ship with the .NET Framework are all built as shared assemblies.

48. If I want to build a shared assembly, does that require the overhead of signing and managing key pairs?

Building a shared assembly does involve working with cryptographic keys. Only the public key is strictly needed when the assembly is being built. Compilers targeting the .NET Framework provide command line options (or use custom attributes) for supplying the public key when building the assembly. It is common to keep a copy of a common public key in a source database and point build scripts to this key. Before the assembly is shipped, the assembly must be fully signed with the corresponding private key. This is done using an SDK tool called SN.exe (Strong Name).
Strong name signing does not involve certificates like Authenticode does. There are no third party organizations involved, no fees to pay, and no certificate chains. In addition, the overhead for verifying a strong name is much less than it is for Authenticode. However, strong names do not make any statements about trusting a particular publisher. Strong names allow you to ensure that the contents of a given assembly haven't been tampered with, and that the assembly loaded on your behalf at run time comes from the same publisher as the one you developed against. But it makes no statement about whether you can trust the identity of that publisher.

49. What is the difference between a namespace and an assembly name?

A namespace is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. Such a naming scheme is completely under the control of the developer. For example, types MyCompany.FileAccess.A and MyCompany.FileAccess.B might be logically expected to have functionality related to file access. The .NET Framework uses a hierarchical naming scheme for grouping types into logical categories of related functionality, such as the Microsoft® ASP.NET application framework, or remoting functionality. Design tools can make use of namespaces to make it easier for developers to browse and reference types in their code. The concept of a namespace is not related to that of an assembly. A single assembly may contain types whose hierarchical names have different namespace roots, and a logical namespace root may span multiple assemblies. In the .NET Framework, a namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

50. What options are available to deploy my .NET applications?

The .NET Framework simplifies deployment by making zero-impact install and XCOPY deployment of applications feasible. Because all requests are resolved first to the private application directory, simply copying an application's directory files to disk is all that is needed to run the application. No registration is required.
This scenario is particularly compelling for Web applications, Web Services, and self-contained desktop applications. However, there are scenarios where XCOPY is not sufficient as a distribution mechanism. An example is when the application has little private code and relies on the availability of shared assemblies, or when the application is not locally installed (but rather downloaded on demand). For these cases, the .NET Framework provides extensive code download services and integration with the Windows Installer. The code download support provided by the .NET Framework offers several advantages over current platforms, including incremental download, code access security (no more Authenticode dialogs), and application isolation (code downloaded on behalf of one application doesn't affect other applications). The Windows Installer is another powerful deployment mechanism available to .NET applications. All of the features of Windows Installer, including publishing, advertisement, and application repair will be available to .NET applications in Windows Installer 2.0.

51. I've written an assembly that I want to use in more than one application. Where do I deploy it?

Assemblies that are to be used by multiple applications (for example, shared assemblies) are deployed to the global assembly cache. In the prerelease and Beta builds, use the /i option to the GACUtil SDK tool to install an assembly into the cache:
gacutil /i myDll.dll
Windows Installer 2.0, which ships with Windows XP and Visual Studio .NET will be able to install assemblies into the global assembly cache.

52. How can I see what assemblies are installed in the global assembly cache?

The .NET Framework ships with a Windows shell extension for viewing the assembly cache. Navigating to % windir%\assembly with the Windows Explorer activates the viewer.

53. What is an application domain?

An application domain (often AppDomain) is a virtual process that serves to isolate an application. All objects created within the same application scope (in other words, anywhere along the sequence of object activations beginning with the application entry point) are created within the same application domain. Multiple application domains can exist in a single operating system process, making them a lightweight means of application isolation.

An OS process provides isolation by having a distinct memory address space. While this is effective, it is also expensive, and does not scale to the numbers required for large web servers. The Common Language Runtime, on the other hand, enforces application isolation by managing the memory use of code running within the application domain. This ensures that it does not access memory outside the boundaries of the domain. It is important to note that only type-safe code can be managed in this way (the runtime cannot guarantee isolation when unsafe code is loaded in an application domain).

54. What is garbage collection?

Garbage collection is a mechanism that allows the computer to detect when an object can no longer be accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a "finalizer," which is written by the user). Some garbage collectors, like the one used by .NET, compact memory and therefore decrease your program's working set.

55. How does non-deterministic garbage collection affect my code?

For most programmers, having a garbage collector (and using garbage collected objects) means that you never have to worry about deallocating memory, or reference counting objects, even if you use sophisticated data structures. It does require some changes in coding style, however, if you typically deallocate system resources (file handles, locks, and so forth) in the same block of code that releases the memory for an object. With a garbage collected object you should provide a method that releases the system resources deterministically (that is, under your program control) and let the garbage collector release the memory when it compacts the working set.

56. Can I avoid using the garbage collected heap?

All languages that target the runtime allow you to allocate class objects from the garbage-collected heap. This brings benefits in terms of fast allocation, and avoids the need for programmers to work out when they should explicitly 'free' each object.
The CLR also provides what are called ValueTypes—these are like classes, except that ValueType objects are allocated on the runtime stack (rather than the heap), and therefore reclaimed automatically when your code exits the procedure in which they are defined. This is how "structs" in C# operate.
Managed Extensions to C++ lets you choose where class objects are allocated. If declared as managed Classes, with the __gc keyword, then they are allocated from the garbage-collected heap. If they don't include the __gc keyword, they behave like regular C++ objects, allocated from the C++ heap, and freed explicitly with the "free" method.

57. How do in-process and cross-process communication work in the Common Language Runtime?

There are two aspects to in-process communication: between contexts within a single application domain, or across application domains. Between contexts in the same application domain, proxies are used as an interception mechanism. No marshaling/serialization is involved. When crossing application domains, we do marshaling/serialization using the runtime binary protocol.
Cross-process communication uses a pluggable channel and formatter protocol, each suited to a specific purpose.
If the developer specifies an endpoint using the tool soapsuds.exe to generate a metadata proxy, HTTP channel with SOAP formatter is the default.
If a developer is doing explicit remoting in the managed world, it is necessary to be explicit about what channel and formatter to use. This may be expressed administratively, through configuration files, or with API calls to load specific channels. Options are:
HTTP channel w/ SOAP formatter (HTTP works well on the Internet, or anytime traffic must travel through firewalls)
TCP channel w/ binary formatter (TCP is a higher performance option for local-area networks (LANs))
When making transitions between managed and unmanaged code, the COM infrastructure (specifically, DCOM) is used for remoting. In interim releases of the CLR, this applies also to serviced components (components that use COM+ services). Upon final release, it should be possible to configure any remotable component.
Distributed garbage collection of objects is managed by a system called "leased based lifetime." Each object has a lease time, and when that time expires, the object is disconnected from the remoting infrastructure of the CLR. Objects have a default renew time-the lease is renewed when a successful call is made from the client to the object. The client can also explicitly renew the lease.

58. Can I use COM objects from a .NET Framework program?

Yes. Any COM component you have deployed today can be used from managed code, and in common cases the adaptation is totally automatic.
Specifically, COM components are accessed from the .NET Framework by use of a runtime callable wrapper (RCW). This wrapper turns the COM interfaces exposed by the COM component into .NET Framework-compatible interfaces. For OLE automation interfaces, the RCW can be generated automatically from a type library. For non-OLE automation interfaces, a developer may write a custom RCW and manually map the types exposed by the COM interface to .NET Framework-compatible types.



59. Can .NET Framework components be used from a COM program?

Yes. Managed types you build today can be made accessible from COM, and in the common case the configuration is totally automatic. There are certain new features of the managed development environment that are not accessible from COM. For example, static methods and parameterized constructors cannot be used from COM. In general, it is a good idea to decide in advance who the intended user of a given type will be. If the type is to be used from COM, you may be restricted to using those features that are COM accessible.
Depending on the language used to write the managed type, it may or may not be visible by default.
Specifically, .NET Framework components are accessed from COM by using a COM callable wrapper (CCW). This is similar to an RCW (see previous question), but works in the opposite direction. Again, if the .NET Framework development tools cannot automatically generate the wrapper, or if the automatic behavior is not what you want, a custom CCW can be developed.

60. Can I use the Win32 API from a .NET Framework program?

Yes. Using platform invoke, .NET Framework programs can access native code libraries by means of static DLL entry points.
Here is an example of C# calling the Win32 MessageBox function:
using System;
using System.Runtime.InteropServices;

class MainApp
{
[DllImport("user32.dll", EntryPoint="MessageBox")]
public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType);

public static void Main()
{
MessageBox( 0, "Hello, this is PInvoke in operation!", ".NET", 0 );
}
}

61. What do I have to do to make my code work with the security system?

Usually, not a thing—most applications will run safely and will not be exploitable by malicious attacks. By simply using the standard class libraries to access resources (like files) or perform protected operations (such as a reflection on private members of a type), security will be enforced by these libraries. The one simple thing application developers may want to do is include a permission request (a form of declarative security) to limit the permissions their code may receive (to only those it requires). This also ensures that if the code is allowed to run, it will do so with all the permissions it needs.
Only developers writing new base class libraries that expose new kinds of resources need to work directly with the security system. Instead of all code being a potential security risk, code access security constrains this to a very small bit of code that explicitly overrides the security system.

62. Why does my code get a security exception when I run it from a network shared drive?

Default security policy gives only a restricted set of permissions to code that comes from the local intranet zone. This zone is defined by the Internet Explorer security settings, and should be configured to match the local network within an enterprise. Since files named by UNC or by a mapped drive (such as with the NET USE command) are being sent over this local network, they too are in the local intranet zone.
The default is set for the worst case of an unsecured intranet. If your intranet is more secure you can modify security policy (with the .NET Framework Configuration tool or the CASPol tool) to grant more permissions to the local intranet, or to portions of it (such as specific machine share names).

63. How do I make it so that code runs when the security system is stopping it?

Security exceptions occur when code attempts to perform actions for which it has not been granted permission. Permissions are granted based on what is known about code; especially its location. For example, code run from the Internet is given fewer permissions than that run from the local machine because experience has proven that it is generally less reliable. So, to allow code to run that is failing due to security exceptions, you must increase the permissions granted to it. One simple way to do so is to move the code to a more trusted location (such as the local file system). But this won't work in all cases (web applications are a good example, and intranet applications on a corporate network are another). So, instead of changing the code's location, you can also change security policy to grant more permissions to that location. This is done using either the .NET Framework Configuration tool or the code access security policy utility (caspol.exe). If you are the code's developer or publisher, you may also digitally sign it and then modify security policy to grant more permissions to code bearing that signature. When taking any of these actions, however, remember that code is given fewer permissions because it is not from an identifiably trustworthy source—before you move code to your local machine or change security policy, you should be sure that you trust the code to not perform malicious or damaging actions.

64. How do I administer security for my machine? For an enterprise?

The .NET Framework includes the .NET Framework Configuration tool, an MMC snap-in (mscorcfg.msc), to configure several aspects of the CLR including security policy. The snap-in not only supports administering security policy on the local machine, but also creates enterprise policy deployment packages compatible with System Management Server and Group Policy. A command line utility, CASPol.exe, can also be used to script policy changes on the computer. In order to run either tool, in a command prompt, change the current directory to the installation directory of the .NET Framework (located in %windir%\Microsoft.Net\Framework\v1.0.2914.16\) and type mscorcfg.msc or caspol.exe.

65. What’s the implicit name and type of the parameter that gets passed into the class’ set method?

Value, and it’s data type depends on whatever variable we’re changing.

66. How do you inherit from a class in C#?

Place a colon and then the name of the base class. Notice that it’s double colon in C++.

67. Does C# support multiple inheritance?

No, use interfaces instead.

68. When you inherit a protected class-level variable, who is it available to?

Classes in the same namespace.



69. Are private class-level variables inherited?

Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.

69. Describe the accessibility modifier protected internal.

It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).

70. C# provides a default constructor for me. I write a constructor that akes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?

Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.

71. What’s the top .NET class that everything is derived from?
System.Object .

72. How’s method overriding different from overloading?

When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.

73. What does the keyword virtual mean in the method definition?
The method can be over-ridden.

74. Can you declare the override method static while the original method is non-static?
No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.

75. Can you override private virtual methods?
No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.

76. Can you prevent your class from being inherited and becoming a base class for some other classes?

Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as final class in Java.

77. Can you allow class to be inherited, but prevent the method from being over-ridden?

Yes, just leave the class public and make the method sealed.

78. What’s an abstract class?

A class that cannot be instantiated.A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over-ridden. Essentially, it’s a blueprint for a class without any implementation.

79. When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?
When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.

80. What’s an interface class?
It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.

81. Why can’t you specify the accessibility modifier for methods inside the interface?
They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it’s public by default.

82. Can you inherit multiple interfaces?
Yes, why not.

83. And if they have conflicting method names?
It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.

84. What’s the difference between an interface and abstract class?
In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.

85. How can you overload a method?
Different parameter data types, different number of parameters, different order of parameters.

86. If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?
Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

87. What’s the difference between System. String and System.StringBuilder classes?
System. String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed

88. How big is the data type int in .NET?
32 bits.



89. How big is the char?
16 bits (Unicode).


90. How do you initiate a string without escaping each backslash?
Put an @ sign in front of the double-quoted string.

91. What are valid signatures for the Main function?
public static void Main ()
public static int Main ()
public static void Main ( string[] args )
public static int Main (string[] args )

92. How do you initialize a two-dimensional array that you don’t know the dimensions of?
int [ , ] myArray; //declaration
myArray = new int [5, 8]; //actual initialization

93. What’s the access level of the visibility type internal?
Current application.

94. What’s the difference between struct and class in C#?
Structs cannot be inherited.
Structs are passed by value, not by reference.
Struct is stored on the stack, not the heap.

95. Explain encapsulation.
The implementation is hidden, the interface is exposed.

96. What data type should you use if you want an 8-bit value that’s signed?
sbyte .

97. Speaking of Boolean data types, what’s different between C# and /C++?
There’s no conversion between 0 and false, as well as any other number and true, like in C/C++.

98. Where are the value-type variables allocated in the computer RAM?
Stack.

99. Where do the reference-type variables go in the RAM?
The references go on the stack, while the objects themselves go on the heap.

100. What is the difference between the value-type variables and reference-type variables in terms of garbage collection?
The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null.

101. How do you convert a string into an integer in .NET?
Int32.Parse( string)

102. How do you box a primitive data type variable?
Assign it to the object, pass an object.

103. Why do you need to box a primitive variable?

To pass it by reference.

104. What’s the difference between Java and .NET garbage collectors?

Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE you’re using. Microsoft standardized on their garbage collection.

105. How do you enforce garbage collection in .NET?

System.GC.Collect ( );

106. Can you declare a C++ type destructor in C# like ~MyClass ()?

Yes, but what’s the point, since it will call Finalize(), and Finalize() has no guarantees when the memory will be cleaned up, plus, it introduces additional load on the garbage collector.

107. What’s different about namespace declaration when comparing that to package declaration in Java?

No semicolon.

108. What’s the difference between const and read only?

You can initialize read only variables to some runtime values. Let’s say your program uses current date and time as one of the values that won’t change. This way you declare public read only string DateT = new DateTime ().ToString ().

109. What does \a character do?

On most systems, produces a rather annoying beep.

110. Can you create enumerated data types in C#?

Yes.

111. What’s different about switch statements in C#?

No fall-throughs allowed.

112. What happens when you encounter a continue statement inside the for loop?

The code for the rest of the loop is ignored; the control is transferred back to the beginning of the loop.

113. Is goto statement supported in C#? How about Java?

Gotos are supported in C# to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality.

posted on 2008-11-04 22:27  ξσ Dicky σξ  阅读(1395)  评论(0编辑  收藏  举报