Pages

Mar 10, 2011

Few Question & Answers About .Net Framework - Part 1

Explain the .Net Framework.

The .Net framework allows infrastructural services to all the applications developed in .net compliant language. It is an engine that provides runtime services using its component like Common Runtime Language. It consists of two main components such as Common Language Runtime and Framework Class Library.

Describe the .Net Framework Architecture. 

The .Net Framework has two main components:
.Net Framework Class Library: It provides common types such as data types and object types that can be shared by all .Net compliant language.

The Common language Runtime: It provides services like code execution, type safety, security, thread management, interoperability services.
 

What are the components of the .Net Framework?

Class Loader, Compiler, Garbage Collection, Type checker, Debug engine, Exception Manager, Security engine, Thread manager, COM Marshallar, Class Library.

Explain the role of assembly in the .Net Framework.

.Net Framework keeps executable code or DLL in the form of assembly. .Net Framework maintains multiple versions of the application in the system through assembly. The assemblies have MSIL code and manifest that contains metadata. The metadata contains version information of the assembly.

Describe the GAC in the .Net Framework. 

.Net Framework provides Global Assembly cache, a machine-wide cache. It stores shared assemblies that can be accessed by multiple languages.

Explain the Debug class methods.

a. Assert:This method checks for a condition. It displays a user message if the condition is false.
b. Write:used to write information which will be used by Trace Listeners.
c. WriteIf:Write information for Trace Listeners only if the condition is true.
d. WriteLine: same as write but, every time writes in a new line.
e. WriteLineIf:same as WriteIf but everytime writes in a new line.

Explain the methods of windows-based authentication

Anonymous authentication gives access to read-only areas of the Web site which do not need any username and password.

Basic Authentication It is done through IIS. This is based on the windows user accounts. When using Basic authentication, the browser lets the user to enter the username and password.
Digest authentication allows sending hash or digesting over the network rather than the plain text as in the case of basic authentication.
Integrated Windows authentication- It is based on users having Windows domain accounts. This type of authentication prevents from pasing the password across the network. It is considered to be the best authentication system over intranet.

What are the ways to optimize the performance of a windows application?

a. Knowing when to use StringBuilder
b. Comparing Non-Case-Sensitive Strings
c. Use string.Empty
d. Replace ArrayList with List<>
e. Use && and || operators
f. Smart Try-Catch
g. Replace Divisions
h. Code profiling
i. Use performance monitor to observe counters written in the application

Explain the key events in the lifecycle of the form.

a. Load: fired when form is first loaded in the application
b. Activated: fired whenever the form gets the focus i.e. when loaded first time, restored from the minimize state, whenever the form is brought in front.
c. Deactivated: fired whenever the form looses focus i.e. when form is closed, minimized, when it is in background.
d. Closing: Triggered when application wishes to be closed.
e. Closed: Triggered when application is closed.
f. Disposed: Used for garbage collection. 

Explain all the windows that help with your debugging.

Call stack: This window provides a description for the flow of application till the current line where the debugger is pointing to. It gives the page information, method name, arguments, line number etc.
Locals: This window provides access and information about all the local variables available at current line. One can see the values of all the local variables/values available at the current line.
Watch: This window has a list of variables that are of interest to the developer. The developer explicitly adds watch to the variables that he is interested in and they all are listed in this window for observation.
Immediate: Immediate window is like a live application paradigm. One can write code in this and see the values that are returned on the basis of current execution of the application. Breakpoints: This window lists all the lines of codes that have a breakpoint and the condition when it will be hit. It also gives the count representing the number of times that breakpoint has been hit.
Output: this window gives a description of assemblies and code that has been loaded by the runtime as the application is being executed.
Autos: This window lists all the available objects present in the current page.
Threads: Lists all the Worker threads along with their unique id, location, category, name priority and suspend status.
Modules: This window lists all the modules available as per the loaded assemblies under the available namespaces. It also tells if they are Optimized, user code, their symbol status, version, timestamp, the process under which they are running information along with the name of the assembly they are in.
Processes: Tells about the processes that are run from this application.

What is the default access modifier for the member? 

  VB.NET C#
Class variable Private Private
Class method Public Private
Structure variable Public Public
Structure method Public Private
  

What are code groups in .NET?

Code group is a logical grouping of code that follows some given conditions for membership. Code groups have some permission sets that are checked before to grant the membership of the code group.
 

Define Data Access Modifier. 

Access Modifiers or Access specifiers provide a class, a variable or a function with accessibility. It means that they govern who can access them.

What are the access modifiers available?    

Answer
There are five different access modifiers:
  • public: It specifies that it can be accessed by anyone.
  • private: Private declared variables, classes or functions can be accessed only by the member functions. No one from outside the class can access them.
  • protected: This access specifier is useful in a hierarchy wherein an access can be given only to the child classes.
  • internal: These limit an access only within an assembly. Its is similar to a friend function of C++.
  • protected internal: These limit the access within the assembly and to the child classes in the hierarchy  

What is strong-typing versus weak-typing? Which is preferred? Why?

In weak typing, it is allowed to define a block of memory as another type (casting).
Languages like C, C++ are weakly and statically typed.
Languages like Perl and PHP are weakly typed as you can add numbers to strings and they will implicitly coerce it.
Languages like Java, C# and Python are strongly typed. In these the type conversion needs to be explicitly handled.
For scripts we use weak typing.
In big programs, we use strong typing which can reduce errors at compile time.