Monday, February 28, 2011

Intw Questions Part1


WCF
.Net 3.5

Safe/Unsafe code
=================
Unsafe code logic [Using unsafe keyword, C# code that makes low-level API calls, pointer arithmetic]
  • CLR is responsible for managing the execution of code compiled for the .NET platform. The code that satisfies the CLR at runtime in order to execute is reffered as Managed Code.
  • C# does not support pointers when creating managed code. Pointers are however both useful and necessary for some types of programming (such as system-level utilities) and C# does allow you to create and use pointers.
    • All pointer operations must be marked as unsafe since they execute outside the managed context.
 
Safe code logic [Fixed Keyword]- Prevent GC to move certain objects


Union All, Union, Minus in SQL
==============================

Sealed class
============
Prevent inheritance

Static Constructors
===================
A static constructor is used to initialize any static data. General constructors are termed as Instance constructors

Impersonation
=============
The term "Impersonation" in a programming context refers to a technique that executes the code under another user context than the user who originally started an application, i.e. the user context is temporarily changed once or multiple times during the execution of an application.

Service Contract and Operation Contract
=======================================
Operation contract is the name of the attribute which is applied to a method inside the interface of a WCF service

Service contract is the name of the attribute which is applied to an interface in a WCF service


Page life cycle
================
Preinit
init
load
loadPre-render
Unload

What’s a satellite assembly?
============================
 When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

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

Every time you use one of the methods in the System.String class, you create a new string object in memory, which requires a new allocation of space for that new object. In situations where you need to perform repeated modifications to a string, the overhead associated with creating a new String object can be costly. The System.Text.StringBuilder class can be used when you want to modify a string without creating a new object. For example, using the StringBuilder class can boost performance when concatenating many strings together in a loop

When you use a normal string and change it, the .net framework will destroy the current string in memory and create a new one somewhere else in the memory. With a stringbuilder the object isn't destr
oyed each time it's adapted

SingletonClass
================
The Singleton is class which only allows a single instance of itself to be created and usually gives access to the instace.

Access Specifier in C#
==================
1. Public: Any member declared public can be accessed from 
outside the class.

2. Private: it allows a class to hide its member variables 
and member functions from other class objects and function. 
Therefore, the private member of a class is not visible 
outside a class. if a member is declared private, only the 
functions of that class access the member.

3. Protected: This also allows a class to hide its member 
var. and member func. from other class objects and 
function, except the child class. it becomes important 
while implementing inheritance.

4. Internal: Internal member can be expose to other 
function and objects. it can be accessed from any class or 
method defined within the application in which the member 
is defined

5. Protected Internal: it's similar to Protected access 
specifier, it also allows a class to hide its member 
variables and member function to be accessed from other 
class objects and function, excepts child class, within the 
application. used while implementing inheritance.
 
Structure and class
====================
The only difference between a structure and a 
class is that all members in a class are private by default whereas they
 are public in a structure. 
 

Intw Questions Part3 (Nvidia)

Value type VS Ref Type
-----------------------------
    * A variable that is of type value directly contains a value. Assigning a variable of type value to another

variable of type value COPIES that value.
    * A variable of type reference, points to a place in memory where the actual object is contained. Assigning a

variable of type reference to another variable of type reference copies that reference (it tells the new object

where the place in memory is), but does not make a copy of the object.


    * Value types are stored on the stack.
    * Reference types are stored on the heap.


    * Value types can not contain the value null. *
    * Reference types can contain the value null.

    * Value types derive from System.ValueType.
    * Reference types derive from System.Object.

    * Changing the value of one value type does not affect the value of another value type.
    * Changing the value of one reference type MAY change the value of another reference type.
------------------------------
Polymorphism/Run time polymorphism, how to acheive run time polymorphism

Managed VS Unmanaged code
Types of array in C#, Jagged array
-------------------------------------
//"jagged" array: araay of(array of int)
int[][] j2 = new int[3][];
j2[0] = new int[] {1, 2, 3};
j2[1] = new int[] {1, 2, 3, 4, 5, 6};
j2[2] = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9};
-------------------------------------
Types of operator in C#, specifically c# operators
--------------------------------------------------------------------------
Primary- I++, I--
Additive- + -
Relational- > < >= <=
Assignment- += -=
Ternary ? :
--------------------------------------------------------------------------
How to control overflow in c#, operator to use that
--------------------------------------------------------------------------
Use checked where it is a possible error condition which you want to catch.
 int square(int i)
    {
        return i * i;
    }
    void f()
    {
        checked
        {
            int i = square(1000000);
        }
    }
--------------------------------------------------------------------------
Virtual Functions
-----------------------------
a virtual function or virtual method is a function or method whose behaviour can be overridden within an inheriting

class by a function with the same signature.
-----------------------------
Compilation of Code in .Net
-----------------------------
Developers using the CLR write code in a language such as C# or VB.NET. At compile time, a .NET compiler converts

such code into CIL code. At runtime, the CLR's just-in-time compiler converts the CIL code into code native to the

operating system.
-----------------------------
Operator Overloading
--------------------------------------------------------------------------
Operator overloading permits user-defined operator implementations to be specified for operations
&&, || They can’t be overloaded
() (Conversion operator) They can’t be overloaded
=, . , ?:, ->, new, is, as, size of These operators can’t be overloaded
In C#, a special function called operator function is used for overloading purpose. These special function or

method must be public and static.
--------------------------------------------------------------------------

Intw Questions Part2

Strengths
Weaknesses


Technical
=========
Reversing a string e.g. "Something is Awesome" to
            => Complete reverse
            => "Awesome is Something"

------------------------------------------------------------------------------------------------------------------
// Reverse the string word by word
            String test= "Testing reversal";
            int len = test.Length;
            string[] strArray = test.Split(' ');
            Console.WriteLine(strArray.Length);
            Console.WriteLine("Reversing String");
          
            for(int i=strArray.Length-1; i>=0; i--)
            {
                if (i>0)
                    Console.Write(strArray[i] + " ");
                else
                    Console.Write(strArray[i]);
        }
            // Reversing String word by word ends here
------------------------------------------------------------------------------------------------------------------
Inserting a node in a link list with Test cases

Delete a node in a link list with Test cases

Factorial program=> With & w/o recursion
Fibonacci program=> with & w/o recursion

Array sorting algorithms

Testing life cycle

Basic powershell scripting