Wednesday 24 April 2013

what are the Tiers? How many Tiers in.Net

There are three tiers . Those are
            1. Single tier , 
            2. Two tier  
            3. 3-tier

How many classes in .Net 4.0

 70000 classes in the Latest VS 2008

What is Satellite Assembly

Every resource file that contains language specific information after compilation gets converted into assembly (except English) those assemblies are known as Satellite Assembly.

write a program for Right to left Stars using C#.Net

program:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class startriangle
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the value:");
            int x = Convert.ToInt32(Console.ReadLine());
            for (int i = 1; i <= x; i++)
            {
                for (int j = 1; j <= x - i; j++)

                    Console.Write(" ");

                for (int k = 1; k <= i; k++)
                    Console.Write("*");
                Console.WriteLine(" ");
            }
            Console.ReadLine();
        }    
    }
}

output: 

What is COM

COM Stands for Component Object Model.

Is arrays support ‘ForEach’ iteration statement

Ans) Yes

What is difference between 1.0 and 2.0 of .Net


.Net 2.0 :
  1. Support for 64 bit application. 
  2. Generics 
  3. SQL cache dependency 
  4. Master Pages 
  5. Membership and roles 

What assemblies can be copied in to GAC

We can copy only strong named assemblies into GAC.

What is MSIL

MSIL stands for MicroSoft Intermediate Language. It can be converted to Source code to Intermediate code is known as MSIL.

What are the two important roles in .Net Framwork

There are two important roles in .net . Those are CLR and BCL
CLR stands for Common Language Runtime 
BCL stands for Base class Library

what is Overloading Method in C#.Net with Examples


Overloading :
                       This allows to define multiple methods in a class with the same name by changing their signatures.


Examples : 



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication1
{
    class overloading
    {
        // no input and out put parameters can be passed.
        public void show()
        {
            Console.WriteLine("method1");
        }


        // one input parameter as int can be passed.


        public void show(int x)
        {
            Console.WriteLine("method2");
        }




        // two input parameter as int's can be passed.


        public void show(int x, int y)
        {
            Console.WriteLine("Method3");
        }


        // two input parameters as string ,int and char can passed.


        public void show(string x, int y, char c)
        {
            Console.WriteLine("method4");
        }


        // Four input parameters as int, float, string , char and bool can be passed.


        public void show(int x, float y, string z, char c, bool k)
        {
            Console.WriteLine("method5");
        }


        // one input parameter as char can be passed.


        public void show(char c)
        {
            Console.WriteLine("method6");
        }


        // one input parameter as int can be passed.


        public void show(double d)
        {
            Console.WriteLine("method7");
        }


        // one input parameter as decimal can passed 


        public void show(decimal dc)
        {
            Console.WriteLine("method8");
        }


        // one input parameter as long can be passed.


        public void show(long l)
        {
            Console.WriteLine("method9");
        }


        // one input parameter as short can be passed.


        public void show(short s)
        {
            Console.WriteLine("method10");
        }


        // two input parameters as string and int can be passed and return type must be string.
        public string show(string s, int x)
        {
            Console.WriteLine("hell " + s +  x);
            return "hello";
        }


        // one input parameters as int and string can be passed and return type must be int.


        public int show(int z, string s)
        {
            Console.WriteLine("this is integer method " +z + s);
            return 1 ;
        }


        //public void show(byte b, sbyte sb, ushort us, uint ui)
        //{
        //    Console.WriteLine("method11");
        //}


        // one input parameter as ulong


        public void show(ulong ul)
        {
            Console.WriteLine("method12");
        }


        // one input parameter as int can be passed , different method and return type must be string.


        public string   show1 (int x)
        {
        
            Console.WriteLine("this is  method  " + x);
            return "hello";
        }


        // No input and out put parameters and different method.


        public void add()
        {
            Console.WriteLine("add method");
        }




        static void show(string s)
        {
            Console.WriteLine(s);
        }


        static string show(bool s)
        {
            Console.WriteLine(s);
            return "show";
        }


        static void Main()
        {
            overloading o = new overloading();
            o.show(20,"hello");


            Console.WriteLine();
            o.show();
            Console.WriteLine();
            o.show(1);
            Console.WriteLine();
            o.show(10,15);
            Console.WriteLine();
            o.show("hello",10,'c');
            Console.WriteLine();
            o.show(20,1.34f,"guraviah",'c', true);
            Console.WriteLine();
            o.show('c');
            Console.WriteLine();


            o.show(1.23);
            Console.WriteLine();
            o.show(50000m);
            Console.WriteLine();
            o.show(996626312111111111);
            Console.WriteLine();
           
            o.show(9966263121111111111);
            Console.WriteLine();
            o.add();
            Console.WriteLine();
            o.show1(12);
            Console.WriteLine();


            o.show("show ",10);
            Console.WriteLine();


            show("Kedar");
            Console.WriteLine();
            show(true) ;


           Console.ReadLine();
        }


    }
}
Output :



example2 : 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class overload1
    {
        static void Main()
        {
            showstring(string.Empty);
            showstring(".Net Developer");
            Console.ReadLine();
        }
        static void showstring(string value)
        {
            if (value == string.Empty)
            {
                Console.WriteLine("Lokesh");
            }
            else
                Console.WriteLine(value);
        }

    }
}

Output : 

Example3 :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication1
{
    class overconstructor
    {
        int x;
        string  y;
        public overconstructor()
        {
            x = 10;
            y ="lokesh";
        }
        public overconstructor(int x, string y)
        {
            this.x = x;
            this.y = y;
            
        }


        //public overconstructor(string  y)
        //{
        //    this.y = y;
        //}


        public void display()
        {
            Console.WriteLine(x);
            Console.WriteLine(y);
        }
        static void Main()
        {
            overconstructor o = new overconstructor();
             overconstructor o1 = new overconstructor();
            o.display();
            o1.display();
            Console.ReadLine();
        }
    }
}

Output :


Below two are Inheritance based Overloading:

Example4 : LoadParent.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication1
{
    class LoadParent
    {
        public void Test()
        {
            Console.WriteLine("method1");
        }
        public void Test(int x)
        {
            Console.WriteLine("method2 " + x);
        }
        public void Test(string s)
        {
            Console.WriteLine("method3");
        }
    }
}

Example 5 : LoadChild.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class LoadChild :LoadParent 
    {
        public void Test(string s, int x)
        {
            Console.WriteLine("method4");
        }
        public void Test(char c)
        {
            Console.WriteLine("method5");
        }
        //public static void Test()
        //{
        //    Console.WriteLine("method6");
        //}
        public void Test(long l)
        {
            Console.WriteLine("method6");
        }

        static void Main()
        {
            LoadChild lc = new LoadChild();
          //  Test();

            lc.Test();
            lc.Test(10);
            lc.Test("lokesh");
           
            lc.Test("guravaiah", 10);
            lc.Test('C');
            lc.Test(923131131131133);

            Console.ReadLine();
        }

    }
}

Output :




Can override a method declared as virtual under any child class ?

Answer :
                  Yes, If the method is declared virtual under a class. Any child class a linear Hierarchy and has  change to override the method.


Examples : 


                       class sealedmethod
                      public virtual void show()
                     class sealedmethod1 : sealedmethod
                      public override void show()
                     class sealedmethod2 : sealedmethod1
                        public   override void show()

What is difference between LINQ and EDM

Linq to Sql : 

  1. It's only work with Sql Server.
  2. Linq to Sql is used for rapid application development.
  3. It does not support for complex types.
  4. It can't generate DataBase from Model.
  5. It's mapping type(Class to single table).
  6. We can query the data using DataContext.
EDM:
  1. EDM works with veriety of DataBase Products.
  2. It can not used for rapid application development.
  3. It provides support for complex types.
  4. It can generate Database from Model.
  5. Mapping type( Class to multiple tables)
  6. We can query data using ESQL,Object Services, Entity Client and Linq to Entities.


what is difference between LINQ and SQL

LINQ :

  • LINQ Stands for language integrated query.
  • LINQ Statements are verify that compile time.
  • To use LINQ we can depend upon our .Net Language syntaxes and also we can consume base class library functionalities.
  • LINQ Statements can be debugged as they execute under framework environment.
SQL :
  • SQL stands for Structured Query Language.
  • SQL statements can be used in a application gets verified for their syntaxes  only in the run time.
  • To use SQL we need to be familiar with SQL syntaxes and also the pre-defined functions of SQL like MAX,MIN,LEN and SUBSTRING  etc...
  • As SQL statements execute on Database server debugging of the code is not possible.

What is MetaData


Metadata contains the information of types under the assembly like Namespaces,Classes and their members(only Signature),Structures and Interfaces etc. Type MetaData only describes about contents of an assembly, so an assembly can be called as self describing unit of execution as it describes about ifself to execution environment with help of its metadata.
Note : When we add reference of any assembly to VS, First VS will read the information  of assembly from its type MetaData.

What is Manifest in .Net


Manifest contains information of attributes that are associated with an assembly like
Title,Description,Company,Version etc

what is the size of the Object in .Net

answer :
                  No fixed size and it can store any type of data.

What is the Remote Class in .Net

           The Remote Class needs to be inherited from the predefined class MarshalByRefObject and implement all the methods that were declared under interface.

What is difference between DatasSet and DataAdapter

 DataSet :

  • DataSet under the System.Data NameSpace.
  • It can hold the data and manage the data within Client System.

DataAdapter : 
  • It is also under System.Data.
  • It is mediator between  DataSet and DataSource.
  • It has two Methods . Those are Fill() and Update()

What is difference between ODBC and Provider in C#.Net

ODBC :

  • ODBC Stands for Open Database Connectivity.
  • To Communicate with remote Databases Microsoft has designed ODBC drivers which facilitates the process of communication with Remote Databases.
OLEDB providers :
  • OleDB Stands for Object linking and embedding database)
  • These are designed purely for DataSource communication and more over a provider sits on the Server machine. So all the clients can use the provider to communicate with the datasource without installing them on client machine.

What is Disconnect-Oriented in ADO.Net

   Disconnect-Oriented :

  • Disconnect-Oriented Architecture is   not permintly connected with  DataSource.
  • It can accept multiple tables at a time.
  • DataSet is under Disconnect-Oriented Architecture.
  • It ca support only forward direction .
  • It is slower in Access.

What is the Command Class in .Net

We can send a request to DataSource specifying the type of action. We want to perform using an SQL statements like select,insert,update and delete. We user  commnad class for executing the statements.
Constructors : 
        command()
        Command(String sqlstmt, connection con)
Properties of Command :
 Connection :  Sets or Gets the current connection object associated with command.
CommandTest : sets or gets the statement associated with command.
Object of class command can be created as below


      Command cmd = new Command();
       cmd.connection= <con>;
        cmd.CommandTest="<sql stmt>";
                      (or)
        Command cmd = new Command("<Sql stmt>",con)

Methods of Command Class :
    ExecuteReader               DataReader
    ExecuteScalar                 object
    ExecuteNonQuery            int

What are the .Net FrameWork Versions

.Net FrameWork Versions are


  •          1.0
  •           1.1
  •           2.0
  •           3.0
  •           3.5
  •           4.0 
Current Version is 4.5

What is Connection-Oriented in ADO.Net

  Connection-Oriented :

  • Connection-Oriented Architecture is always connected with DataSource.
  • It can accept only one table at a time.
  • DataReader is under Connected -Oriented Architecture.
  • It ca support both forward direction and backward Direction.
  • It is faster in Access.

What are the Advantages of DataSet and DataReader in .Net

 Advantages of DataSet and DataReader  :

Dataset : 

  • Dataset provide disconnected mode.
  • We can use DataRelation between table in Dataset.
  • DataSet contain Hug of Data from DataBase.
  • DataSet can load  from other Resource like XMLfile.


What are the Disadvantages of DataSet and DataReader in .Net

Disadvantages of DataSet and DataReader  :
DataSet : 
  • Dataset is slower in compare to RecordSet Because at first data convert in xml before providing to the user.
  • We cannot use frequent changes data in dataset because it works as a disconnected mode.

Friday 12 April 2013

What is Garbage collector in .Net

                      Garbage collector is responsible for automatic allocation and deallocation of computer resources for programs.

What is Globalization in .Net

Involves writing the executable code for an application in such a way that makes it cluture-neutral and language-neutral. While incorporating globalization, you must ensure that the culture-specific details are not hard-coded into the executable code. The primary task in this phase is to identify the various locale-sensitive resources and to isolate these resources from the executable code.

Can we consume a class of project from a class of another project?

 Answer :
                Yes, We can consume but not directly as they were to add reference of the assembly in which the class was present to the project who wants to consume it.

What is Localization in .Net


                      Involves the customization of an application for a specific locale. One major task in this phase is the translation of resources identified during the globalization phase. During this phase, various resources, such as images and text , for the designated locale are created.
v  The utmost basic entity in this scenario is Culture. The Culture information (usually called CultureInfo) includes the Language, Country/Region, Calender,Formats of Date, Currency,number System, and Sorting Order.This all information is defined inside CultureInfo Class, Which is inside the namespace System.Globalization.
v  According to MSDN,The culture names follow a standard in the format “<languagecode>-<country>”, where <languagecode> is a lowercase two-letter code and <country> is an uppercase two-letter code.
v  The object raised from this class, when set true will be changing the culture of your application.But it’s never so that you make an application. In English culture,and raise an object of CultureInfo class for French language and automatically everything will start working for French.
v  For each cultures’ UI that is the text , images you want to see over the forms you will have to define the translations explicitly. This information is known as resources , and they exist in form of .resx files . These are xml files , and to read , write,manage them there are various classes listed under System.Resources namespace.

How to restrict a class not be accessible to any other class?

                     This can be done by declaring Constructor of class Private

What is an Event in .Net

An Event is an action which is fired based on behavior of the object. In graphical development i.e in GUI. We generally have event driven programming. Different languages provide different types of programming for events. .Net/JavaScript provide events as function pointers.

What is Presentation Layer in .Net

This layer should contain only code related to presentation

How many times Constructor called

Only once.

What are the Providers in ADO.Net? Why?


OLEDB Provider: (Object Linking and Embedded Database)
                These are designed purely for data source communication and more over a provider sits on the server machine. So all the clients can use the provider to communicate with the data source without installing them on client machine.
Note: Both the Drivers and Providers suffers from a common drawback.i.e they were designed using native code languages. Because of this they were purely dependent on the O.S.
                Because of the native language supports under visual basic language. VB was not able to communicate  with drivers and providers directly. So it used some few intermediate component to communicate with drivers and Providers.

What is Single Call in Remoting

 In this mode whenever a request comes from a client one object of remote class gets created and it’s reference is given to client, once the request is served immediately object gets destroyed without allowing him to make any other requests on that object, for a new request a new object gets created again and destroyed. Used in the development of single request application like “Railway PNR Status Enquiry”, “TM Machines” and “Examination Results”.
Note : This is very highly secured model used in application development.

what is difference between class and structure in .net

 The Main difference of Both is :

 Class : 
  1. It was a Reference Type.
  2. Supports all the features of OOP'S.
  3. Gets it's memory allocated on managed heap. Because of this garbage collector provides memory management.
  4. Not faster in access than structure.
  5. Require a new operator for object creation.
  6. Default constructor in this was optional.
  7. Supports both implemenation and interface inheritance.
Structure :
  1. It was a value type.
  2. Doesn't support all the features like inheritance.
  3. Gets it's memory allocated on stack. Because of this garbage collector can't manage the memory .
  4. Faster in access.
  5. Doesn't require a new operator for object creation which was only optional.
  6. Default constructor in this was mandatory.
  7. Supports only interface inheritance.

What is Public Key Token in .Net

As GAC contains multiple assemblies in it, to identity assemblies it will maintain a key value for every assembly known as public key token , which  should be generated by us and associate with an assembly to make it strong named.

What is Business Layer in .Net

All validations / Calculations related  to UI as well as Data Access layer should be performed using Business Layer.

What are the Marshalling and Un-Marshalling in Remoting


  1.  After serializing the data which has to be sent to the target machine it packages the data into packets this is what we call as marshalling,at this time it associates the IP Address of the target machine where the information has to be sent. UnMarshalling is in opposite to Marshalling which opens the packets of data for de-serializing.
  2. 2. IP-Address:  Every system in a network is identified by using a unique id known as IP Address. It is a 4 par numeric value where each part will be ranging between 0-255. Eg: 0-255.0-255.0-255.0-255
  3. v   We can mask IP Address of a system by specifying an alias name to it known as HostName. Systems under a network will be configured as following:

IP Address                       HostName
92.168.26.0                         (guru0)
……………….                         …………
192.168.26.24                 (guru24)

How many classes a ‘dll’ can contain?


ans) Two classes those are control library and class Library.

What is the best place to store the connection string

In Web.config or App.Config

What is default Access Specifier in .Net

Ans)    internal

What is DataAdapter in .Net

DataAdapter is class  and it is under System.Data NameSpace. It is mediator between DataSource and DataSet.

What is difference between from 1.1 to 4.0

 First Start with difference between .Net 1.0 and 2.0

  1. Generics
  2. Membership and roles
  3. Master pages
  4. Sql Cache Dependancy
  5. Support 64 bit Application
Next difference between .net 2.0 and 3.0
  1. WPF
  2. WCF
  3. WWF
  4. WCS ( Card Space)
Next difference between .Net 3.0 and 3.5
  1. Ajax Inbuilt
  2. LINQ
  3. ADO Entity Framework
  4. MultiTargetting
Final Difference between .Net 3.5  and 4.0
  1. MEF
  2. Parallel Computing
  3. DLR Dynamic

What are the Features of Visual Studio 2008

When compared to previous versions of visual studio. Some features added in visual studio 2008 those are 
  •   Multi Targetting
  •   Ajax Inbuilt
  •   LINQ
  •     EDM 
  

What is ExecutenonQuery in ADO.Net

 ExecuteNonQuery is a method.When we want execute the DML statements like Insert,Update and Delete. Where the method returns the number of rows effected.

What is those in CLR

Ans)  jit + econjit

What are the Serialization and Deserialization in Remoting


v                             To exchange information between both the parties they make use of a process known as Serialization and De-Serialization . As applications represent the data in High Level(Object Format) Which are not free flowable , needs to be converted into low level(Binary or Text) and then transferred to the other system. Where on the target machine Low Level data has to be converted back into high Level.
v                               Serialization is a process of converting high level data to low level and De-Serialization is in opposite of serialization that converts low level data to high level.
v  To perform Serialization and De-Serialization remoting provides Formatter Classes, Those are:
·         Binary Formatters :        -- TCPServerChannel     --TCPClientChannel
·         Soap Formatters :           -- HttpServerChannel    --HttpClientChannel
v                                Binary Formatters are used for binary Serialization and De-Serialization & Soap Formatters are used for text Serialization and de-serialization.
v  Note :  Traditional DCOM supports only Binary.

what is difference between c#.net and Vb.net

C#.NET :

  1. C#.Net supports unsigned int and it is case sensitive.
  2. Strongly typed language.
  3. Supports operator overloading.
  4. Supports Pointers.
  5. Supports auto XML documentation 
  6. Supports Automatic Memory management.
VB.NET:
  1. VB.Net doesn't support unsigned int and it is not case sensitive.
  2. losely typed language.
  3. No operator overloading.
  4. No Pointers.
  5. No auto XML document.
  6. No automatic Memory Management.

what is difference between constant and readonly

constant :

  • Constant is used to at the time of declaration is mandatory.
  • constant can't be modified within a class.
                ex: const float pi=3.14f;


readonly :

  • readonly is used to optional for declaration of values.
  • readonly can be modified with the class 
            ex: readonly string str;

What is difference between Do While and Do Until

 Difference between Do While and Do Until is Do While executes the statements in Loop when condition is TRUE and exits from the loop when condition is FALSE.
But Do Until executes the statements in loop when condition is FALSE and exits from the loop when condition TRUE.



Do While :
                                             Do While < Condition>
                                                     <Statement>
                                                       Inc/Dec of VAR
                                                      [ exit do]
                                                     Loop

Example :

                   Dim N as Integer =1
                    Do While  N <=10
                   Console.Write(N)
                   N+1=1
                 Loop

Out Put :  1  2  3  4 -------- 10


Do Until  :

                          Do Until< Condition>
                                                     <Statement>
                                                       Inc/Dec of VAR
                                                      [ exit do]
                                                     Loop


Example :

                                       Dim N as Integer =1
                                       Do Until N >10
                                      Console.Write(N)
                                         N+ =1
                                          Loop


Out Put :  1  2  3  4 -------- 10


What is Optional Parameter in .Net

                                 When a  procedure is created with  N number of parameters then while calling the procedure you must pass N number of arguments . When we want to allow the user to call procedure with variable number of arguments and not fixed number of argument then C++  provides the concept Default arguments and similar to this vb.net provides Optional Parameters.
                               To declare the parameters has Optional parameter use the keyword Optional. When  a parameter is declared with the keyword optional then it compulsory initialize it. The value to which it is initialized is called as default argument. When we are not passing argument for the optional parameter then default argument will be take. A rule to declare optional parameter is they must be last parameter in the parameter list.

Example : The following example creates a function with the name sum with five parameters but allows the user to call the function sum with two or three or four or five arguments

                Module OptionalParameters
           Function Sum(Byval  A as integer, Byval  b as integer, OPtional Byval  C as integer=0,OPtional Byval  D as integer=0 , OPtional Byval  E as integer=0) As integer
            Return A+B+C+D+E
End Function
Sub Main()
Console.WriteLine(sum(10,20))
Console.WriteLine(sum(10,20,30))
Console.WriteLine(sum(10,20,33,44))
Console.WriteLine(sum(10,20,33,44,32))
End Sub
End Module


What is ParamArray Parameter in .Net

                      To allow the user  to pass any number of arguments of same data type to a parameter . We have to declare the parameter has an array. But when a parameter is declared as an Array then while calling the procedure, We must pass an array as argument and it is not possible to pass individual elements as arguments. To allow the user to pass an array of an argument or individual elements seperated with comma(,), we have to declare the parameter has ParamArray parameter.
                        To declare the parameter as ParamArray parameter , We have to prefix the parameter declaration with the keyword ParamArray .  ParamArray parameters have the following restriction.

  1. A procedure can have only one ParamArray Parameter
  2. ParamArray parameter must be last parameter in the parameter list.
  3. ParamArray parameter cannot be optional parameter.
  4. ParamArray parameter cannot be reference Parameter.
Example : The following example creates a Function with the name Sum that can accept any number of integers and returns their sum.

      Module  ParamArrayparameter
         Function Sum( Byval ParamArray A() as integer) As Integer
           Dim S as Integer
            For Each N as Integer in A 
           S+ =N
      Next
                     (OR)

       For Each N as Integer=0 in A.GetupperBound(0)
             Dim S as Integer
              S+ = A(i)
              Next
Return S
End Function

Sub Main()
Dim A() as integer = {1,2,3,4,5}
Console.WriteLine(Sum(A())
Console.WriteLine(Sum(A(22,33,44,5,55,22))
End Sub 
End Module.