Wednesday, August 02, 2006

ASP.NET Page Life Cycle

Clear understanding of ASP.NET Page life cycle
http://blogs.crsw.com/mark/articles/471.aspx

  1. Constructor()
  2. AddParsedSubObject()
  3. DeterminePostBack()
  4. OnInit()
  5. LoadPageFromPersistenceMedium()
  6. LoadViewState()
  7. ProcessPostData()
  8. OnLoad()
  9. ProcessPostData()
  10. RaiseChangedEvents()
  11. RaisePostBackEvent()
  12. OnPrerender()
  13. SaveViewState()
  14. SaveViewStatetoPersistenceMedium()
  15. OnPrerender()
  16. Render()
  17. Dispose()

Few more general questions in .NET

All these questions are taken from http://blogs.crsw.com/mark/articles/252.aspx

  • CCW : Com Callable wrapper.
  • RCW : RUN time callable wrapper.
  • foo.gettype() ,Gettype(foo)
  • ASP . Interprepter.. use the script engine but ASP.Net Compiled
  • Microsoft Intermeidate lanaguage. which is the out put for all the .net supported languages after comiplation will produce. Appreciation for cross language support.
  • What base class do all Web Forms inherit from? System.Web.UI.Page
  • malloc, alloc, release
  • ASP.NET is a technology that provides a framework for developing .NET based web applications.
  • ASP.NET is not a platform independen language. ASP.NET is more of a technology that provides a framework for building web applications. ASP.NET provides the reources needed to dynamically deliver html content (pages) to the end user. ASP.NET can leverage languages such as C#, VB.NET, and javascript to help provide a reliable, high perfofmance, and secure web application.
  • .net framework is independent because msil is independent can be run anywhere. but it is platform dependent because msil wil be converted to native code which is understandable by windows.
  • What is serialization, how it works in .NET?
  • What should one do to make class serializable?
  • What exactly is being serialized when you perform serialization?
  • scope in C#
  • The primary purpose of XML serialization in the .NET Framework is to enable the conversion of XML documents and streams to common language runtime objects and vice versa. Serialization of XML to common language runtime objects enables one to convert XML documents into a form where they are easier to process using conventional programming languages. On the other hand, serialization of objects to XML facilitates persisting or transporting the state of such objects in an open, standards compliant and platform agnostic manner.
  • Serialization is the process of converting an object or a con-nected graph of objects into a contiguous stream of bytes. Deserialization is the process of converting a contiguous stream of bytes back into its graph of connected objects. The ability to convert objects to and from a byte stream is an incredibly useful mechanism. Here are some examples:
  • An application's state (object graph) can easily be saved in a disk file or database and then restored the next time the application is run. ASP.NET saves and restores session state by way of serialization and deserialization.
  • A set of objects can easily be copied to the system's clipboard and then pasted into the same or another application. In fact, Windows® Forms uses this procedure. • A set of objects can be cloned and set aside as a backup while a user manipulates the main set of objects.
  • A set of objects can easily be sent over the network to a process running on another machine. The Microsoft® .NET Framework remoting architecture serializes and deserializes objects that are marshaled by value. Why would you want to use serialization? The two most important reasons are to persist the state of an object to a storage medium so an exact copy can be recreated at a later stage, and to send the object by value from one application domain to another.
  • Static methods
  • copyto method makes a deep copy and clone method makes a shallow copy
  • What is web garden?
  • What is object pooling?
  • Tell some thing about IIS isolation levels.
  • Dispose is the method, which we call usually when we want the object to be garbage collected. If u r calling Dispose() on inbuilt classes like Form, It'll call a method Finalize() method, which will usually used to cleanup any resources used with in the form. With in this Finalize method, we call the garbage collector to recycle the memory. So, when u r using dispose method, it is used to mark the object to Garbage Collectable. Calling the Dispose dose't means, that object will b garbage collected immidiately. GC will monitor the Managed memory for objects Marked 4 garbage collectable. The recycling of memory depends on when the GC will pay the visit. Purely the Dispose method is not used for reseting the values in the object. It is used to mark the Object to b collected by the GC
  • What are the different types of assemblies – name them?Private Public/Shared Satellite assembly
  • This Global Assembly Cache(GAC) stores .NET assemblies to be shared by several applications on that computer.
  • How many ways can we maintain the state of a page? 1.Client Side [ Query string, hidden variables, view state,cookies] 2.Server side [application , session, database]
  • What is the purpose of a private constructor? [Rama Naresh Talluri] Prevent the creation of instance for a class
  • Differentiate Dispose and Finalize. [Rama Naresh Talluri] Finalize is called by the Garbage Collector, and the state of manage objects cannot be guaranteed, so we can not reference them. Also, we cannot determine when the GC will run, and which objects it will Finalize. Dispose is called by the programmer, and is used to dispose of managed and unmanaged objects. Within we dispose method, we release all of our resources and call GC.SuppressFinalize as we have done the work of the GC.
  • What is the purpose of Singleton pattern? [Rama Naresh Talluri] Singleton pattern is used to make sure that only one instance of a given class exists.
  • What is the difference between well formed and valid xml document ?
  • 1. Explain about Normalization?
  • 2. What is the difference between union & union all?
  • 3. What kind of transactions can handled?
  • 4. temporay tables use & how we can manage?
  • 5. perfomance tuning steps? 6. Difference btn method overload / override?
  • 7. When Garbage collector come into picture?
  • 8. Difference btn refernce & value types?
  • 9. boxing / unboxing in ASP.NET
  • 10. assemblies
  • 11. What manifest file contains?
  • 12. MSIL
  • 13. JIT
  • 14. clas vs module
  • 15. dataadapter
  • 16. dataset
  • 17. ado.net objects
  • 18. difference btn and, and also
  • 19. dataset.copy & dataset.clone
  • 20. code access security
  • 21. finalization
  • 22. strogn type dataset

Excellent Questions

Net topics

1. Define what is meant by the term “data structure”?

A data structure is an abstract struct or class that is used to organize info and provide various manipulations on their enclosed data. The most common data structure would be array, but there are many well-known structures in .NET including hashtables, queues, and other collection classes (even custom) that can be made into Binary Search Trees and other usable data structures for the specific programming problem at hand.

2. What is MSIL (Microsoft Intermediate Language) and how is it generated? MSIL is machine-independant code (similar to java bytecode in and ASM sort of way…) that describes instructions of a program. The main purpose of MSIL is to run implementations of the programs defined metadata (which is stored in an assembly with the specific AppDomain) so that the CLR can utilize this ‘bluprint’ and bring a program to life. Metadata and MSIL is generated by a compiler, and can be inspected through ILDASM or .NET Reflector (third-party free program). For example csc.exe is the compiler for CSharp code.

3. What is Garbage Collection?

Garbage Collection is a hassle-free way to free up assigned memory spaces during the runtime execution of a managed code program. By using Garbage Collection (in a enhanced implementation than Java does..) we can write managed code programs without worrying about the number of objects we are instantiated at runtime or the proper disposal of those objects. The Garbage collector will determine when the object is no longer going to be used within a programs execution, and will flag it for ‘pickup’, however pickup does not actually occur until additional memory is needed by the program, and hence garbage collection can occur randomly throughout the execution lifetime. You can equate and think about this in terms of the benefits of being able to program against heap memory versus stack memory. The awesome thing about GC is that it frees us from worries of dangling pointers, circular references, or memory leaks (and blue screens).

4. What is Serialization? What 2 formats does dot net provide?

Serialization is a means in which to take and object, and be able to map its structure or class graph into a stream. The purpose of which normally is to transfer that object to another location, or persist custom obejects to some form of storage. .NET provides two main implementation classes for serialization.. the XML Soap Formatter and the BinaryFormatter class. You must implement the IFormatter interface to actually write out to these streams using the Serialize or Deserialize methods, and you can mark classes unserializable or serializable using Attributes in your code.

5. What is the GAC (Global Assembly Cache) used for?

The GAC is a shared ‘dumpsite’ for assemblies you wish to strong-name and share across multiple app domains. This is a great way to shared common components (like rich-text box controls or custom mail classes). The GAC is used for this data store component sharing ability, as well as for storing code downloaded from the internet (in a private portion of the cache), and for storing native code versions of pre-JIT assemblies.

5. Is a String a value or reference type? What is the difference between the two? A String in .NET is an immutable object comprised of char objects. Since these objects last as constant throughout their instantiated lifetime (hence are immutable) they are treated as value types. Value types are usually simple types such as integers, floats, and other objects as opposed to user-defined types such as a customer object in a customers class. The major difference between value and reference types are how they are treated in allocated memory… value types are copied in memory and reference types are usually shallow-copied, basically a memory pointer of sorts points (or references) the memory address of the original object. Most reference types are shallow-copied unless specifically coded for a deep-copy implementation (as may be required in late-binding scenarios). The .NET framework takes care of most boxing and unboxing of types as required. In a value type, what the called method does with the incoming parameter doesn’t affect the variable passed down from the calling method. With a reference type, when the called method makes changes to the data through the reference, the changes are made to the original data.

C#

1. What are the as and is keywords used for?

‘is’ is used to check if an object is compatible with a given type against its run-time type, and ‘as’ is used to perform conversions between compatible types. The ‘as’ operator is used in an expression form, like “expression as type’

2. What is the using keyword used for?

Using is similar to the Java imports directive, which allows us to reference a namespace.. This allows us to refer to members of that namespace, without having to utilize its fully-qualified name. For example, if I want to use regular expressions features, I should add a using directive in order to access members of that namespace without their FQN. “using System.Text.RegularExpressions;” The keyword ‘using’ is overloaded however, and can be used as a statement for an object that wants to implement IDisposable.

3. What is the out and ref keyword used for in functions and how do they differ?

The out keyword is used for parameters assigned within the called method, and passed by reference back out of that called method.. the ref keyword is for parameters assigned prior to the call to that particular method (functions should be referred to as methods in .NET by the way…) and the parameter is being passed by reference, not by-value.

4. What is a delegate?

A delegate is a type that defines a methods signature so the delegate can hold and invoke a method of that same signature.. In the term of Chess pieces.. a delegate would be akin to a King’s Bishop.. who could hold or act on the King’s orders. Delegates are powerful mechanisms for the event model of .NET, and allows us to multicast delegates… that is allow us to raise multiple events or notify multiple delegates of an event, or event to raise events sequentially.

5. What is the difference between a struct and a class?

A struct (or structure) is lightweight compared to all the features of a class, basically because it is a value type, wherin a class is a reference type. We usually use structures for desirable semantics such when we want an assignment to copy a value rather than a reference.. Classes can have destructors, which structs cannot have, and classes can have parameterless constructors.. which structs cannot have. Stucts are sealed classes, but can implement interfaces like classes can.

Object Oriented Design principles

1. What is method overloading and method overriding?

Overloading a method generally refers to creating multiple signatures of that method, allowing us to call that method with differentiating parameters in order to run a differentiating operation. For example, a engine class might have one method for start() intended for a gasoline engine, and another method of start(nGlowPlugTime) meant for a diesel engine. In such case, the start() method would be overloaded. Overriding a method is when we want to take a base class definition of a method, and change the implementation details of that method in the derived class by rewriting it to suit our specifications. Essentially this goes hand-in-hand with the virtual and override keywords in .NET We can override abstract, virtual or override declared methods, but we could not override sealed classes for example.

2. Describe two uses of the new keyword in .NET.

The new operator is most often used to instantiate a new instance of an object (create new memory allocation on the heap and invoke constructors for that object). New can also be used as a modifier, in order to explicitly hide a derived class member from the base class… Such a implementation would look like new public void Start()

3. What is the difference between interfaces and inheritance?

Wow.. great question.. hehe… inheritance usually in .NET is thought of as a single-inheritance model, not multiple.. so for example my child could inherit my bad habits, but not both my own and my wife’s bad habits (We would have to override all those bad habits anyway..) interfaces are contracts that programmers should implement (in fact, they must implement) when creating a class. My best analogy for an interface is a standard Universal TV Remote Control.. although it can turn on any television, the actual implementation of that particular IR signal is dependent on the make/model of the TV you are trying to turn on.. hence the “ON” would be exposed as an interface… surely you would have to implement this interface in order to actually get the thing to really work. However interfaces can be utilized to get to a sort-of pseudo multiple inheritance model if utilized correctly and in written in proper fashion.

4. What is an abstract data type? How is one defined in C#? Abstract methods provide no actual implementation details, and an abstract data type, or abstract property, behave similar. An abstract inherited property could be overridden and implemented in a derived class by declaring that property with the override modifier. We define it in C# with the abstract modifier. Abstract data types are implicitly virtual, and hence could not be static members (static members are when a single instantiated object is constant throughout the application..)

5. What is polymorphism used for? Polymorphism is best described as multiple uses for a particular object. If I were to create a 35 in 1 tool for example, that particular tool has 35 polymorphic uses. Each of those uses could require a specific implementation (or contract) in order to achieve the desired results. For example, the Draw() method for shapes is polymorphic, depending on whether I would draw a circle, square, polyhedron, etc.. the method could indeed be used, hence it would need polymorphism. True polymorphism is generally a multiple-inheritance model, and hence you would need to turn to interfaces to achieve the desired results as opposed to simple inheritance which could be achieved by overloading the methods.

Databases T-SQL

1. What is the difference between HAVING and WHERE clauses? Having behaves like a where clause when improperly used, that is having should be used in a SELECT statement with a GROUP BY clause. WHERE is used to restrict the results returned, wherin having should be used to group results or restrict results by aggregate.

2. What is the difference between TRUNCATE and DELETE? I am a big fan of TRUNCATE… especially with MySQL, but it essentially is the same in SQLServer… it removes all the rows of a table without logging the individual deletions.. and it doesn’t have any WHERE clauses in its usage.. hence it is generally less resource-intensive, and surely faster than, DELETE. DELETE walks through all the rows one-by-one, yet truncate just deallocates the data pages used, usually with less locks on the database table.

3. What is an index? An index can be created on tables and views, and is like an index of a book, it lets the database quickly find the data it is indeed looking for in response to the given query. It contains keys that relate to storage locations of the individual data contained within columns for which the index is defined. Indexes open up critical database considerations in speed and execution and are best left to experienced DBA’s who understand the ramifications of the index, for example, indexing small tables or having a large number of indexes on a table could drastically affect performance.

4. What is a clustered and non-clustered index? A clustered index is one in which the logical order of the keys in the index equates to the physical order of the data rows in the DB. An indexed view is actually a clustered index that is unique for example. A clustered index needs to be explicitly created, generally before any nonclustered indexes. With nonclustered indexes, their physical order is independent of the index keys, and this is the default implementation of indexes.

5. What is an instead of trigger? A instead of trigger specifies it will be executed in replecement of the triggering SQL statement. In SLQ 2005, we can execute DDL triggers on DB schema, but instead of cannot be executed on DDL queries, only on DML T-SQL… and there can only be one instead-of instance per INSERT, UPDATE or DELETE. In addition, we could not replace the SQL statements in a DELETE with a cascade action, hence instead of would not be allowed in such a situation.

6. Given a table named User having a single nullable column named UserName, what is the SQL statement that will return a result set that contains the total number of non-NULL UserName? SELECT COUNT(ALL UserName) FROM User

ASP.Net

1. What is viewstate and where is it stored by default?

The viewstate is a page-level state preservation mechanism, most-often used between postbacks to persist the state of controls on the page. It is stored in encrypted hidden fields on the page (__VIEWSTATE__). There are multiple Page declaration attributed that can be used for the viewstate, including turning it on or off, encrypting it, allowing viewstate to persist for example on Server.Transfer requests, etc. It is a great lightweight persistence mechanism, but for pages that never change control state, or pages with very large data-intensive result sets.. the viewstate is best not employed.

2. What does the SmartNavigation page directive do? It doesn’t do anything anymore.. its deprecated… But what it had done in the past, is allow asp.net to return to the same control area on the page during a postback, to prevent users from scrolling again to a particular region of the page. It utilized a feature buit-in to IE5 that would remember the element focus and scroll position on a page. You will now see many SmartNavigation warnings in your VisualStudio error box on building older code on the new ASP.NET 2.0 framework about it’s deprecation.

3. What interface(s) do I need to implement when designing custom web controls that raises servers-side events? I believe you would have to implement the IDispose interface for sure to clean up after the page is unloaded, and perform any other final cleanup work. Usually custom server-side controls are developed to encapsulate reusable code so that a html tag can be dropped into a page and that custom control is brought to life (like a custom Web grid, etc.) By encapsulating the functionality we could respond to events and set the control properties, hence there should be a mechanism that ensures a custom-control is cleaning up after itself.. o IDispose would certainly fit the bill.

4. What are the 3 authentication types that ASP.Net supports?

The most common authentication method is Forms based authentication, followed by Windows-based authentication, and finally Passport authentication.. the former of which is under revision into the new Windows Live features and service set.. There is a fourth type of authentication really, that is NO authentication, which would rely on the inherit capabilities of IIS, or perhaps a custom-built http module that would run before the asp.net module is hit.. Custom modules would be extremely ineffective in a shared web farm situation for example, which would benefit from authenticating users under a centralized user credential service such as Microsoft Passport offers.

5. Between which page life cycles stages is the viewstate loaded?

The viewstate is loaded between the InitComplete event and Page_Load events.. in ASP.NET 1.x, you must wait for the Load event to start to safely write to any control viewstate. Ulitmately, the StateBag class of the framework is responsible for the viewstate that manages information, and it works like a dictionary collection class, allowing you to get and set data as appropriate.

ESRI Interview Questions

After grilling 8 interviews from 9am to 5pm, i was completely exhausted.
Here a few questions, I remember....
  • What is GAC
  • How to deploy an assembly
  • Exception handling(multiple catch statements)
  • Life cycle of a thread in java, web service
  • Difference between jsps and servlets
  • what is ngen.exe ?
  • dll hell?
  • What is CLR?
  • XML and XPath
  • Ajax