You must Sign In to post a response.
  • Category: .NET

    My Interview Questions

    Hi to all,
    I have some questions frequently asked in Interview am faced. For those Questions i don't know how to answer properly. Kindly provide me the answer for those questions.

    1. Which Scenario Abstract and Interface are need?
    2. Difference b/w framework 3.5 and 4.0?
    3. Major diff. from vb.net and c#?
    4. what is static Method?
    5. why we have to use 3 tier architecture?
    6. Difference string and String Builder?
    7. Differ. bw Stored Procedure and Functions?
    8. Session Management?
    9. Garbage Collection?
    10.Assembly?
  • #763245
    4. what is static Method?
    1.Static methods are called with classname.method name directly with out creating object.
    2.When we have all static methods in a class, then we can declare that class as static class.
    3.Some static methods are as follows
    Console.ReadLine(); // consoleclass.methodname
    Console.Write();
    MessageBox.Show();

    class static sample2
    {
    public static void display()
    {
    MessageBox.Show("Am from static method");
    }
    button click
    {
    sample2 obj=new sample2(); // error . As we cannot create object for static class.
    obj.display(); // this is error. cannot be accessed with object.
    sample2.display(); //works fine as called with classname.methodname
    }

    6. Difference between string and StringBuilder?
    String:
    String is said to be immutable because we cannot change after string object is once created.
    If we try to change the value of string object, another new string object is created with modified value.
    Every time we change value a new object is created.

    Stringbuilder:
    Stringbuilder is said to be mutable because we can change value after object is created.
    Changing the value will not create new object instead existing value is modified.
    Every time we change value a new object is not created.

    1. Which Scenario Abstract and Interface are need?
    http://www.dotnetspider.com/forum/332773-Abstract-Class-and-InterFace.aspx

    http://www.dotnetspider.com/resources/20897-What-Difference-Between-Interface-abstract.aspx

    Sridhar Thota.
    Editor: DNS Forum.

  • #763248
    Answers
    1. Basically If you want to provide common, implemented functionality among all implementations of your component, use an abstract class, If you are designing small, concise bits of functionality, use interfaces
    2. Any new version has its own features and functioanalities, framework 4.0 has following new things which are not exist in 3.5
    - Client Profile framework is introduced for faster deployment
    - Portable class library is introduced which will run on a variety of .NET Framework platforms without recompiling
    - Improvement in globalization namespace and garbage collection
    - Support for the MVVM pattern across both WPF and Silverlight

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #763253

    Hi,

    These all are basic questions while attend the interview, I will provide single line definition for all those, if you want more descriptive then please check with Google.

    1. Which Scenario Abstract and Interface are need?
    A) If you want to inheritance multiple class information then we go for interface.
    If you want to override parent class information in child then we go for Abstract class.

    2. Difference b/w framework 3.5 and 4.0?
    A) Refer below link "differencebetween.com/difference-between-microsoft-net-framework-3-5-and-net-framework-4-0/"

    3. Major diff. from vb.net and c#?
    A) Syntactic difference, if you want to know detailed then refer below link "en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Visual_Basic_.NET"

    4. what is static Method?
    A) A method should contain static keyword, we called this as a static method, we can invoke those methods directly using class name.

    5. why we have to use 3 tier architecture?
    A) Re-usability of the code, maintainability, and easy implementation.

    6. Difference string and String Builder?
    A) String :
    1) namespace using System;
    2) immutable, value will not be overwritten in the memory allocate new memory for new variable

    StringBuilder:
    1) namespace using System.Text;
    2) mutable, value will overwritten in the memory.

    7. Differ. bw Stored Procedure and Functions?
    A) Stored Procedure:
    1) We can call procedure inside another procedure
    2) we can call function inside procedure
    3) return value is optional
    4) We can use Try and catch blocks.

    Functions:
    1) we can't call SP inside function.
    2) we can't able to call function inside another function.
    3)return value is mandatory
    4) can't able to use try and catch blocks in functions.

    8. Session Management?
    A) It is server side state management, we can able to store bulk of data. Using session we can able to maintain state through out application(include multiple pages) until session expire. Default session timeout is 20 mins. We can able to increase it by changing Session timeout property in web.config.


    9. Garbage Collection?
    A) It's destroy the unwanted memory after MSIL convert the code into native language.

    10.Assembly?
    A) When you Compile project it's generates 2 types of assemblies
    a) dll - dynamic link library
    b) exe- executable files.
    It generates multiple versions for each and every time of compilation.

    Hope you understand the explanation if you want to know more about each and every functionality then I suggested you to go through Google and ask the same.


    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #763259
    5.Why we have to use 3 tier architecture?
    We use 3 tier architecture to differentiate the business logic, database connectivity, database logic and the UI(User Interface).
    By using this it makes possible for individual people work on individual modules.
    And we can identify easily the code blocks, if we face and issue related to database we directly go to the database layer and we modify the code.

    8. Session Management?
    As we know the http is a state less protocol, we need to handle that using state management techniques.
    Session is a server side state management technique.
    String s=Session["variable"];

    9. Garbage Collection?
    CLR(comman language runtime) internally clears the unused objects implicitly with the help of garbage collection mechanism.
    It clears or removes only the managed code.
    Garbage collection is under control of CLR.

    Sridhar Thota.
    Editor: DNS Forum.

  • #763288

    1. Which Scenario Abstract and Interface are need?
    Ans:- Both abstract classes and interfaces are used when there is a difference in behaviour among the sub-types extending
    the abstract class or implementing the interface.When the sub-types behaviour is totally different then you use an
    interface, when the sub-types behaviour is partially common and different with respect to the supertype an abstract class
    is used. In an abstract class the partially common behaviour is given a concrete implementation. Since there is no common behaviour between an interface and a sub-type an interface does not have an implementation for any of its behaviour.


    2. Difference b/w framework 3.5 and 4.0?
    Ans:- The main difference between .NET 3.5 and .NET 4.0 are as follows :-

    · The web installers for .NET 4.0 are below 1MB in size and faster internet connection is required to download the bits.
    · In .NET 3.5, there is no direct method for accessing data whereas there is an in-built feature for data access in .NET 4.0.
    · Enableviewstage property has two values in .NET 3.5 as "True" and "False" whereas in .NET 4.0, this property has three values as Inherit, Disable and Enable.
    · .NET 4.0 is the most improved version of .NET 3.5 and now it is widely used in IT industry by large organizations.



    3. Major diff. from vb.net and c#?
    Ans :- The basic differences are as follows :-
    Advantages VB.NET: -

    · Support for optional parameters which makes COM interoperability much easy.

    · With Option Strict off late binding is supported.Legacy VB functionalities can be used by using Microsoft.VisualBasic namespace.

    · Has the WITH construct which is not in C#.

    · The VB.NET part of Visual Studio .NET compiles your code in the background. While this is considered an advantage for small projects, people creating very large projects have found that the IDE slows down considerably as the project gets larger.

    Advantages of C#


    · Use of this statement makes unmanaged resource disposal simple.

    · Access to Unsafe code. This allows pointer arithmetic etc, and can improve performance in some situations. However, it is not to be used lightly, as a lot of the normal safety of C# is lost (as the name implies).This is the major difference that you can access unmanaged code in C# and not in VB.NET.



    4. what is static Method?
    Ans :- A static thing stands alone. It occupies just one location. The static modifier is used on methods, classes,
    constructors. Static denotes things that are singular. They are part of no instance. Static often improves
    performance, but makes programs less flexible. No instance is required—this makes them slightly faster.
    Static methods can be public or private. Static methods use the static keyword, usually as the first keyword or
    the second keyword after public. A static method cannot access non-static class level members.
    It has no "this" pointer. For e.g.

    C# program static methods :-

    using System;

    class Program
    {
    static void MethodA()
    {
    Console.WriteLine("Static method");
    }


    static char MethodC()
    {
    Console.WriteLine("Static method");
    return 'C';
    }


    static void Main()
    {
    //
    // Call the two static methods on the Program type.
    //
    Program.MethodA();
    Console.WriteLine(Program.MethodC());
    }
    }

    Output

    Static method
    Static method
    C




    5. why we have to use 3 tier architecture?
    Ans :- The 3-Tier architecture generally contains UI or Presentation Layer, Business Logic Layer and Data Access Layer (DAL).
    · Presentation Layer (UI) Presentation layer cotains pages like .aspx or windows form where data is presented to the user or input is taken from the user.
    · Business Logic Layer BLL contains business logic, validations or calculations related with the data, if needed.
    · Data Access Layer (DAL) DAL contains methods that helps business layer to connect the data and perform required action, might be returning data or manipulating data (insert, update, delete etc).

    Uses of 3-Tier Architecture:
    1. To make application more understandable.
    2. Easy to maintain, easy to modify application and we can maintain good look of architecture.



    6. Difference string and String Builder?
    Ans :- The basic difference between string and String Builder is as follows :-
    String is immutable whereas StringBuilder can have mutable string where a variety
    of operations can be performed.


    7. Differ. bw Stored Procedure and Functions?
    Ans :- The difference between Stored Procedure and Functions are as follows:-
    · Stored Procedure is a pre-compiled object whereas function is not.
    · Stored Procedure can raise errors but in case of function it cannot raise errors.
    · Stored Procedure either return one or more value or not return any value whereas function can return only one value.
    · All the DML and DDL operations (i.e. Select, Insert, Update, Delete) can be used by Stored Procedure whereas function is only used by the 'SELECT' statement.





    8. Session Management?
    ASP.NET allows us to save values using Session state. It is a global storage mechanism that is accessible from all pages in the Web application. Session state is stored in the Session key/value dictionary. This information will be user specific i.e. for each user separate dictionary will be created and no one can access other session information. below is the Example usage of sessions.
    Following are the session management techniques are present in the ASP.NET framework.
    ·In-Proc.
    ·SQLServer.
    ·StateServer.



    9. Garbage Collection?
    Ans:- Garbage collection is a CLR feature which automatically manages memory.CLR automatically releases objects when they are no longer in
    use and refernced. CLR runs on non-deterministic to see the unused objects and cleans them. One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when
    it goes out of the scope of a function. Therefore, we should not put code into a class destructorto release resources.

    10.Assembly?
    Ans:- Assembly is unit of deployment like EXE or a DLL. An assembly consists of one or more files
    (dlls, exe's, html files etc.), and represents a group of resources, type definitions, and
    implementations of those types. An assembly may also contain references to other assemblies.
    These resources, types and references are described in a block of data called a manifest.
    The manifest is part of the assembly, thus making the assembly self-describing.
    An assembly is completely self-describing. An assembly contains metadata information,
    which is used by the CLR for everything from type checking and security to actually invoking the components methods.
    For private assembly deployment, the assembly is copied to the same directory as the client program that references it.
    Just delete it from the hard drive. In shared assembly deployment, an assembly is installed in the Global Assembly Cache (or GAC).
    The GAC contains shared assemblies that are globally accessible to all .NET applications on the machine.


Sign In to post your comments