SlideShare a Scribd company logo
.NET Technical Check & Tuneup Senthil Kandasamy [email_address]
Today's Topics Standard Technical vetting Uncommon Problems & common answers 'it' Depends: Real Life Issues What do you read is what you are!
Warm Up Questions Is “string” value or reference type? It is a reference type. string is an alias of String  Is int[] counter is a value or reference type? Arrays are intrincically derived from System.Array.  Is Nullable types are value or reference type? All nullable types are of Type System.Nullable<T> struct Is it possibe to define a variable of type  Nullable<Nullable<int>> number; int  ?? number;
Rapid Fire Round Why Generics? Allows to design class or method that defer the specification of one or more types until used by client. Avoids Boxing and Unboxing (Performance) Avoids Runtime exceptions (type safety) Better programming (Code reuse) What type would return if “is” operator is used on  List< int > counterList = null; Underlying type will be returned not the Nullable type.
The very Basics (Not Visual Basic) Can delegates added to invocation list be changed? NO Does delegates are invoked once for each time they appear in the invocation list? Yes it does. Can multiple catch blocks be executed?   No.  Can return statement in try block make finally block called? Yes.
Dot Net Framework What is the difference between private and shared assembly Accessibility by applications. Shared assembly has to be Strong Named, have version and culture. Installed in GAC.  What does Reflection do? Runtime type discovery Load Assemblies Dynamic Invocation What is an &quot;IS&quot; operator? Equiv of Type
I PC Which one of the following correctly initializes the ThreadStart object myStart?     1    ThreadStart myStart = new ThreadStart(); 2    ThreadStart myStart = new ThreadStart(myThread);       3    ThreadStart myStart = new ThreadStart(DoSomething()); 4    ThreadStart myStart = new ThreadStart(DoSomething);      5    ThreadStart myStart = new ThreadStart(this); How to achive synchronization in .NET? Using lock(object) statement for the critical section. What is Thread Pool? Collection of threads
Whyow to do multithreading? To compute operations in parellel.   By acquiring threads from ThreadPool class .  When you call the  Thread.Start  method on a thread, will it start immediately? That thread does not start executing until the current thread yields or is preempted by the operating system.
What happens when an Object is serialized? Name of class, assembly and data members What are the two format types that XMLSerializer generates in Web Service? Litteral (RPC style) and encoded (SOAP) Both can be handled in by applying attributes like SoapElementAttribute and XMLElementAttribute Can SqlConnection object be serialized? NO.
What are different formatter that can be used in Serialization? BinaryFormatter, XmlFormatter, SoapFormatter What is the new tool that is introduced in .Net 2.0 for creating an XML serialization assembly? XML Schema Definition Tool (Xsd.exe)  What is an Object Graph?  An object model that is neither cyclic nor a tree. How to: Catch a non-CLS Exception? Within a catch block type the exception as RuntimeWrapperException
  How Do I Serialize Generic Types? Presently, .NET  does not  provide a mechanism for constraining a  generic  type  parameter to be serializable.  What happens when an invoked method throws exception in Multicast Delegate? If an invoked method throws an exception, the method stops executing, the exception is passed back to the caller of the delegate, and remaining methods in the invocation list are not invoked. Catching the exception in the caller does not alter this behavior.
Where forwarding event happens in ASP.NET? A GridView control can contain one or more buttons created dynamically by templates . How can an  ASP.NET  application deployed in server farm? Externalize the Session State We know ViewState what is ControlState? Property that allows you to persist property information that is specific to a control and cannot be turned off
It Depends What happens when we add an assembly to a client? It depends, private assembly local copy gets created. Shared assembly with public key do not.
Do static constructor need in a class? It depends, Performing the constraint verification in the static constructor is a technique applicable to any constraint that you cannot enforce at compile time. Can this custom object public class Employee{ private String _name;} stored in  ASP.NET Session? It-depends, if in-process  yes. if out-of-Process the objects has to be serializble
Which parser is best for reading XML Document It depends, XMLReader, XMLTextReader, XMLValidatingReader, XPATH, XMLDocument   Will setting AutoPostBack property to true - do postback? It depends, if client side script is turned on. How to do cross-page posting in ASP.NET? This can be done by configuring individual controls
Cross-Page versus Server.Transfer Cross-Page posting Posts current page information to the target page. Makes post information available in the target page. Requires user initiation. Redirects to any page, not just pages in the same Web application. Enables the target page to read public properties of the source page if the pages are in the same Web application Server.Transfer Transfers control to a new page that renders in place of the source page. Redirects only to target pages that are in the same Web application as the source page. Enables you to read values and public properties from source page. Does not update browser information with information about the target page. Pressing the refresh or back buttons in the browser can result in unexpected behavior.
How to: Determine How ASP.NET Web Pages Were Invoked Examine the values of the following  Page  class properties IsPostBack PreviousPage IsCrosssPagePostBack IsCallBack What is adaptive Rendering?
OleDbParameter param = new OleDbParameter(); param.SourceVersion = DataRowVersion.Proposed; Under what circumstances does specifying the SourceVersion affect the behavior of a parameter attached to a command? 1  Only when bound to a data adapter as an  DeleteCommand 2  Only when bound to a data adapter as an  InsertCommand 3  Only when bound to a data reader 4  Only when bound to a data adapter as an  SelectCommand 5  Only when bound to a data adapter as an  UpdateCommand
Things to Avoid When Throwing Exceptions Should not change the flow of the process Should not be returned as return value or passed in as parameter instead of being thrown Do not create exceptions that can be thrown in debug mode but not release mode. To idventify run-time errors during the development phase, use Debug Assert instead Do not throw System.Exception, System.SystemException, System.NullReferenceException, System.IndexOutOfRangeException intentionally from your own source code.
Threading  Static state must be thread safe. Avoid syncronization for instance variables. Don't use  Thread.Abort  to terminate other threads.  Use Mutex Don't control the execution of worker threads from your main program  Avoid DeadlockRace Condition Performance consideration
Version behavior in Serialization Never remove a serialized field. Never apply the  NonSerializedAttribute  attribute to a field if the attribute was not applied to the field in the previous version Never change the name or the type of a serialized field. When adding a new serialized field, apply the  OptionalFieldAttribute  attribute. When removing a  NonSerializedAttribute  attribute from a field (that was not serializable in a previous version), apply the  OptionalFieldAttribute  attribute. For all optional fields, set meaningful defaults using the serialization callbacks unless 0 or  null as defaults are acceptable
Software Design Principles
Open - Closed Principle Object should be  open for extension  but  closed for modifications
Single Responsibility Principle Object should have only  one  reason to change
Dependancy Inversion Principle Both high and low level modules should  depend on abstractions , not on each other Details should depend on abstractions not the other way
Liskov's Substitution Principle Derived types must be  completely substitutable  for their base types
Interface Segregate Principle Clients should not be  forced to depend  upon interfaces that they don't use
Books I Read  
Boston User Groups (...I Attend) Boston .NET Certification Group  http://tech.groups.yahoo.com/group/bostondotnetcertification/     Boston .NET Architecture Study Group  http://tech.groups.yahoo.com/group/boston_dotnetarchitecture/   New England ASP.NET Professionals User Group  http://neasp.net/     New England SQL Server User Group  http://www.nesql.org/default.aspx      Beantown.NET User Group  http://beantowndotnet.org     Boston .NET User Group  http://www.bostondotnet.org/
10 Commandments - Summary Join LinkedIn Participate in community activities Answer questions in user groups Attend Monthly meetings Get Certified - Brainbench; MCPD/MCTS; OCA/OCP Blog - Book Reviews; Knowledge dumps; Obscure Bugs  Twit Regularly on all of the above  Commit to a Passion Play some games - Get an Avatar Don't do any of the above - Just Relax & do a codeplex project!
Questions for me?

More Related Content

How to ace your .NET technical interview :: .Net Technical Check Tuneup

  • 1. .NET Technical Check & Tuneup Senthil Kandasamy [email_address]
  • 2. Today's Topics Standard Technical vetting Uncommon Problems & common answers 'it' Depends: Real Life Issues What do you read is what you are!
  • 3. Warm Up Questions Is “string” value or reference type? It is a reference type. string is an alias of String Is int[] counter is a value or reference type? Arrays are intrincically derived from System.Array. Is Nullable types are value or reference type? All nullable types are of Type System.Nullable<T> struct Is it possibe to define a variable of type Nullable<Nullable<int>> number; int ?? number;
  • 4. Rapid Fire Round Why Generics? Allows to design class or method that defer the specification of one or more types until used by client. Avoids Boxing and Unboxing (Performance) Avoids Runtime exceptions (type safety) Better programming (Code reuse) What type would return if “is” operator is used on List< int > counterList = null; Underlying type will be returned not the Nullable type.
  • 5. The very Basics (Not Visual Basic) Can delegates added to invocation list be changed? NO Does delegates are invoked once for each time they appear in the invocation list? Yes it does. Can multiple catch blocks be executed?   No. Can return statement in try block make finally block called? Yes.
  • 6. Dot Net Framework What is the difference between private and shared assembly Accessibility by applications. Shared assembly has to be Strong Named, have version and culture. Installed in GAC.  What does Reflection do? Runtime type discovery Load Assemblies Dynamic Invocation What is an &quot;IS&quot; operator? Equiv of Type
  • 7. I PC Which one of the following correctly initializes the ThreadStart object myStart?    1    ThreadStart myStart = new ThreadStart(); 2    ThreadStart myStart = new ThreadStart(myThread);      3    ThreadStart myStart = new ThreadStart(DoSomething()); 4    ThreadStart myStart = new ThreadStart(DoSomething);      5    ThreadStart myStart = new ThreadStart(this); How to achive synchronization in .NET? Using lock(object) statement for the critical section. What is Thread Pool? Collection of threads
  • 8. Whyow to do multithreading? To compute operations in parellel.   By acquiring threads from ThreadPool class .  When you call the Thread.Start method on a thread, will it start immediately? That thread does not start executing until the current thread yields or is preempted by the operating system.
  • 9. What happens when an Object is serialized? Name of class, assembly and data members What are the two format types that XMLSerializer generates in Web Service? Litteral (RPC style) and encoded (SOAP) Both can be handled in by applying attributes like SoapElementAttribute and XMLElementAttribute Can SqlConnection object be serialized? NO.
  • 10. What are different formatter that can be used in Serialization? BinaryFormatter, XmlFormatter, SoapFormatter What is the new tool that is introduced in .Net 2.0 for creating an XML serialization assembly? XML Schema Definition Tool (Xsd.exe)  What is an Object Graph?  An object model that is neither cyclic nor a tree. How to: Catch a non-CLS Exception? Within a catch block type the exception as RuntimeWrapperException
  • 11.   How Do I Serialize Generic Types? Presently, .NET does not provide a mechanism for constraining a generic type parameter to be serializable. What happens when an invoked method throws exception in Multicast Delegate? If an invoked method throws an exception, the method stops executing, the exception is passed back to the caller of the delegate, and remaining methods in the invocation list are not invoked. Catching the exception in the caller does not alter this behavior.
  • 12. Where forwarding event happens in ASP.NET? A GridView control can contain one or more buttons created dynamically by templates . How can an  ASP.NET  application deployed in server farm? Externalize the Session State We know ViewState what is ControlState? Property that allows you to persist property information that is specific to a control and cannot be turned off
  • 13. It Depends What happens when we add an assembly to a client? It depends, private assembly local copy gets created. Shared assembly with public key do not.
  • 14. Do static constructor need in a class? It depends, Performing the constraint verification in the static constructor is a technique applicable to any constraint that you cannot enforce at compile time. Can this custom object public class Employee{ private String _name;} stored in  ASP.NET Session? It-depends, if in-process  yes. if out-of-Process the objects has to be serializble
  • 15. Which parser is best for reading XML Document It depends, XMLReader, XMLTextReader, XMLValidatingReader, XPATH, XMLDocument   Will setting AutoPostBack property to true - do postback? It depends, if client side script is turned on. How to do cross-page posting in ASP.NET? This can be done by configuring individual controls
  • 16. Cross-Page versus Server.Transfer Cross-Page posting Posts current page information to the target page. Makes post information available in the target page. Requires user initiation. Redirects to any page, not just pages in the same Web application. Enables the target page to read public properties of the source page if the pages are in the same Web application Server.Transfer Transfers control to a new page that renders in place of the source page. Redirects only to target pages that are in the same Web application as the source page. Enables you to read values and public properties from source page. Does not update browser information with information about the target page. Pressing the refresh or back buttons in the browser can result in unexpected behavior.
  • 17. How to: Determine How ASP.NET Web Pages Were Invoked Examine the values of the following Page class properties IsPostBack PreviousPage IsCrosssPagePostBack IsCallBack What is adaptive Rendering?
  • 18. OleDbParameter param = new OleDbParameter(); param.SourceVersion = DataRowVersion.Proposed; Under what circumstances does specifying the SourceVersion affect the behavior of a parameter attached to a command? 1 Only when bound to a data adapter as an DeleteCommand 2 Only when bound to a data adapter as an InsertCommand 3 Only when bound to a data reader 4 Only when bound to a data adapter as an SelectCommand 5 Only when bound to a data adapter as an UpdateCommand
  • 19. Things to Avoid When Throwing Exceptions Should not change the flow of the process Should not be returned as return value or passed in as parameter instead of being thrown Do not create exceptions that can be thrown in debug mode but not release mode. To idventify run-time errors during the development phase, use Debug Assert instead Do not throw System.Exception, System.SystemException, System.NullReferenceException, System.IndexOutOfRangeException intentionally from your own source code.
  • 20. Threading Static state must be thread safe. Avoid syncronization for instance variables. Don't use Thread.Abort to terminate other threads.  Use Mutex Don't control the execution of worker threads from your main program  Avoid DeadlockRace Condition Performance consideration
  • 21. Version behavior in Serialization Never remove a serialized field. Never apply the  NonSerializedAttribute  attribute to a field if the attribute was not applied to the field in the previous version Never change the name or the type of a serialized field. When adding a new serialized field, apply the  OptionalFieldAttribute  attribute. When removing a  NonSerializedAttribute  attribute from a field (that was not serializable in a previous version), apply the  OptionalFieldAttribute  attribute. For all optional fields, set meaningful defaults using the serialization callbacks unless 0 or  null as defaults are acceptable
  • 23. Open - Closed Principle Object should be open for extension but closed for modifications
  • 24. Single Responsibility Principle Object should have only one reason to change
  • 25. Dependancy Inversion Principle Both high and low level modules should depend on abstractions , not on each other Details should depend on abstractions not the other way
  • 26. Liskov's Substitution Principle Derived types must be completely substitutable for their base types
  • 27. Interface Segregate Principle Clients should not be forced to depend upon interfaces that they don't use
  • 29. Boston User Groups (...I Attend) Boston .NET Certification Group http://tech.groups.yahoo.com/group/bostondotnetcertification/   Boston .NET Architecture Study Group http://tech.groups.yahoo.com/group/boston_dotnetarchitecture/ New England ASP.NET Professionals User Group http://neasp.net/   New England SQL Server User Group http://www.nesql.org/default.aspx   Beantown.NET User Group http://beantowndotnet.org   Boston .NET User Group http://www.bostondotnet.org/
  • 30. 10 Commandments - Summary Join LinkedIn Participate in community activities Answer questions in user groups Attend Monthly meetings Get Certified - Brainbench; MCPD/MCTS; OCA/OCP Blog - Book Reviews; Knowledge dumps; Obscure Bugs  Twit Regularly on all of the above Commit to a Passion Play some games - Get an Avatar Don't do any of the above - Just Relax & do a codeplex project!

Editor's Notes

  1. This session is just not a brain dump of a technical interview on Microsoft technologies. It will be refresher on various pieces of the .NET, Database, OO, Process world. It will serve as a caution for interviewers to red flag their questions which are circulated on the webdom. For all the inquisitive and MCP certified brains, this will serve as a ‘whodunnit’ challenge. It will be a useful reference for the rest of us. The talk is divided into four sections. We will cover the typical BrainBench type questions to start with. Then we will attack the common problems encountered on the field and ideal solution paths to each of them. Third part will be about architectural trade-offs and ‘it depends’ scenarios. Finally, there will be discussion on best practices, books needed for interview preparation and open Q&amp;A among the participants.
  2. Equality operators == AND != confusing. 2The System.Array type offers several static and instance members. Since all arrays are implicitly derived from System.Array, these members can be used to manipulate arrays of value types or reference types. You&apos;ll also note that Array implements several interfaces: ICloneable, IEnumerable, ICollection, and IList. These interfaces allow arrays to be conveniently used in many different scenarios. Figure 2 summarizes the methods offered by System.Array and the interfaces that it implements. Casting Arrays Passing and Returning Arrays Fast Array Access 3. Nullable types are of struct which is a value type stored in stack. 4. Nullable types allow underlying value types.
  3. 2. IsGenericTypeDefintion method is used. Calling GetType on a Nullable type causes a boxing operation to be performed when the type is implicitly converted to  Object . Therefore  GetType  always returns a  Type  object that represents the underlying type, not the Nullable type.
  4. 1 Delegates are immutable; once created, the invocation list of a delegate does not change. 2. once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block 3. Finally block that follows a try block will get executed
  5. 3. Used to check the run-time type of an object is compatible with a given type.
  6. Tasks in the back ground. Requests are processed asynchronously Returns to queue of waiting threads.
  7. 1. are stored in the file. 3. Object that implements ISerializable interface or class decorated with [Serializable] can be serialized.
  8. 1. The workaround is to perform a single run-time check before any use of the type, and abort the use immediately, before any damage could take place. You can place the run-time verification in the static constructor.
  9. If the Cli
  10. If a parent class has set “rules” on behavior, than the child must adhere to those “rules” for their behavior as well. Therefore, if the child is filling in for the parent, no behavior would be in violation of the “rules” defined by the parent. This is assuming the child is a good little boy or girl. Now with that picture in your head, let’s go back to our little “Animal Walking” business. Animal is the “parent” class in this example and has set behaviors: Eat(Food), Sleep(Hours) and Walk(Pace). This will mean that all “child” classes will need to implement these behaviors and have an appropriate post condition. As you can see in the example, the Dog is a little more lax in the food department. However, the Cat can only restrict its diet to the IFood interface. Restricting food any further would violate Liskov’s Substitution Principle because it would require the calling class to know about each animal’s behavioral differences. The Cat’s Sleep(Minutes) method is an example of this. The Cat class could not be substituted for the Animal class because it restricts the caller more than expected. Because the Cat class expects minutes (under the hood) instead of hours, the caller will not pass the proper parameters and the system will suffer accordingly. This principle also states that output cannot be restricted any further than the constraints made by the parent class. Therefore, if the output from the Eat() method is a percentage of how hungry the animal remains, then a child could not output the amount of time it took to finish the meal. This would confuse the user and in turn violate LSP. Output must not violate the constraints of the parent and user of the class must not be confused by the output as well.