ASP .NET Interview Questions (Part-3)

In this article, I will discuss Important Interview Questions about Variables and Data Types.

Let’s start with the questions:

Question # 1: What are Value Type and Reference Type?

Value type variable directly contains the value whereas reference type variables contain a memory location where actual value exists. It only points to that memory location.

Value type variables are located in the stack and reference type variables exist in the heap.


Question # 2: What is the Difference between passing value type and Reference type variables?

When we pass a value type variable into a function, it creates a copy of that variable in memory. Changing the value in function will not affect its value outside the function.

If we pass a reference type variable into the function, the program actually passes its memory location to the function. Changing the value in function also changes it outside the function.


Question # 3: What are Stack and Heap?

Stack is a special area in computer memory to store temporary variables, it is a linear data structure. Here we can have limited memory but faster access to data.

Heap is a hierarchical data structure where memory size has no limit but data access speed is comparatively slow. Actual data of reference type variables get stored here.


Question # 4: What is Implicit and Explicit typecasting?

We can easily store a variable of smaller data type (let’s say int) into a variable or larger data type (for example double). C# will automatically do typecasting. This is called Implicit typecasting.

However to store larger type variables into smaller data type variables you need to manually convert its type. This is called explicit typecasting.


Question # 5: What are Boxing and Unboxing?

Converting a value type variable to an object is called boxing and converting it back to value type is called unboxing.

Boxing is an Implicit action and unboxing is explicit.


All these questions are very important for the Interview because many people get confused about these concepts, that’s why I tried to explain these concepts in easy words. I hope this article will clear all your confusion.

Here is the video where I explained these questions in very easy words.

Must watch this video (In Urdu):

Posted: 07 May 2021

Visit for more

Joined in Nov 2020

I am Programmer, I love writing about technology. You can contact me for any suggestions & feedback about this website. Keep writing & reading awesome articles.

() ()