.NET Programming Concepts - .NET Interview Questions and Answers

Why ".NET - .NET Programming Concepts" Interview Questions?

In this section you can learn and practice interview questions based on "".NET - .NET Programming Concepts"" and improve your skills in order to face the interview, competitive examination and various entrance tests (CAT, GATE, GRE, MAT, Bank Exam, Railway Exam etc.) with full confidence.

Where can I get ".NET - .NET Programming Concepts" interview questions and answers with explanation?

IndiaBIX provides you lots of fully solved ".NET - .NET Programming Concepts" interview questions and answers with Explanation. All students, freshers can download ".NET - .NET Programming Concepts" quiz questions with answers as PDF files and eBooks. Solved examples with detailed answer description, explanation are given and it would be easy to understand. View the solution for the problems with feel and good user interface; easily go through all questions and answers.

How to answer ".NET - .NET Programming Concepts" interview questions?

You can easily answer the interview questions based on ".NET - .NET Programming Concepts" by practicing the exercises given below.

  1. Define variable and constant.
    A variable can be defined as a meaningful name that is given to a data storage location in the computer memory that contains a value. Every variable associated with a data type determines what type of value can be stored in the variable, for example an integer, such as 100, a decimal, such as 30.05, or a character, such as 'A'.

    You can declare variables by using the following syntax:

    <Data_type> <variable_name> ;

    A constant is similar to a variable except that the value, which you assign to a constant, cannot be changed, as in case of a variable. Constants must be initialized at the same time they are declared. You can declare constants by using the following syntax:

    const int interestRate = 10;
  2. What is a data type? How many types of data types are there in .NET ?
    A data type is a data storage format that can contain a specific type or range of values. Whenever you declare variables, each variable must be assigned a specific data type. Some common data types include integers, floating point, characters, and strings. The following are the two types of data types available in .NET:
    • Value type - Refers to the data type that contains the data. In other words, the exact value or the data is directly stored in this data type. It means that when you assign a value type variable to another variable, then it copies the value rather than copying the reference of that variable. When you create a value type variable, a single space in memory is allocated to store the value (stack memory). Primitive data types, such as int, float, and char are examples of value type variables.
    • Reference type - Refers to a data type that can access data by reference. Reference is a value or an address that accesses a particular data by address, which is stored elsewhere in memory (heap memory). You can say that reference is the physical address of data, where the data is stored in memory or in the storage device. Some built-in reference types variables in .Net are string, array, and object.
  3. Mention the two major categories that distinctly classify the variables of C# programs.
    Variables that are defined in a C# program belong to two major categories: value type and reference type. The variables that are based on value type contain a value that is either allocated on a stack or allocated in-line in a structure. The variables that are based on reference types store the memory address of a variable, which in turn stores the value and are allocated on the heap. The variables that are based on value types have their own copy of data and therefore operations done on one variable do not affect other variables. The reference-type variables reflect the changes made in the referring variables.

    Predict the output of the following code segment:

    int x = 42; 
    int y = 12;
    int w;
    object o;
    o = x;
    w = y * (int)o; 
    /* The output of the code is 504. */
  4. Which statement is used to replace multiple if-else statements in code.
    In Visual Basic, the Select-Case statement is used to replace multiple If - Else statements and in C#, the switch-case statement is used to replace multiple if-else statements.
  5. What is the syntax to declare a namespace in .NET?
    In .NET, the namespace keyword is used to declare a namespace in the code.

    The syntax for declaring a namespace in C# is:
    namespace UserNameSpace;

    The syntax for declaring a namespace in VB is:
    Namespace UserNameSpace
  6. What is the difference between constants and read-only variables that are used in programs?
    Constants perform the same tasks as read-only variables with some differences. The differences between constants and read-only are

    1. Constants are dealt with at compile-time.
    2. Constants supports value-type variables.
    3. Constants should be used when it is very unlikely that the value will ever change.

    1. Read-only variables are evaluated at runtime.
    2. Read-only variables can hold reference type variables.
    3. Read-only variables should be used when run-time calculation is required.