Are you tired of your old job? Are you looking to start your new career as a Dot Net Developer? Wisdomjobs got everything you needed to pursue your dream job and to face today's competitive world. Dot Net is a powerful, flexible software framework that can be adapted to a broad range of uses. Dot Net developer should be efficient in using C and VB.NET languages. Dot Net jobs are highest payable jobs in India and abroad. Visit our wisdom jobs portal to access Dot Net Developer interview questions and answers page to improve your skills and successful interview. Register at our jobs portal to access all the information needed to apply for your dream job and to successfully clearing the interview.
Answer :
The variables that are based on reference types store references to the actual data.
The keywords that are used to declare reference types are:
Answer :
The variables that are based on value types directly contain values.
The characteristics of value-type variables that are supported in C# programming language are as follows:
The value type consists of two main categories:
Question 3. Define Variable And Constant.?
Answer :
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;
Question 4. Determine The Output Of The Code Snippet.?
Answer :
int a = 29;
a--;
a -= ++a;
Console.WriteLine("The value of a is: {0}", a);
/* The output of the code is -1. */
Question 5. Differentiate Between Boxing And Unboxing.?
Answer :
When a value type is converted to an object type, the process is known as boxing; whereas, when an object type is converted to a value type, the process is known as unboxing.
Boxing and unboxing enable value types to be treated as objects. Boxing a value type packages it inside an instance of the Object reference type. This allows the value type to be stored on the garbage collected heap. Unboxing extracts the value type from the object. In this example, the integer variable i is boxed and assigned to object obj.
Example:
int i = 123;
object obj = i; /* Thi line boxes i. */
/* The object obj can then be unboxed and assigned to integer variable i: */
i = (int)obj; // unboxing
Question 6. Differentiate Between The While And For Loop In C#.?
Answer :
The while and for loops are used to execute those units of code that need to be repeatedly executed, unless the result of the specified condition evaluates to false. The only difference between the two is in their syntax. The for loop is distinguished by setting an explicit loop variable.
Question 7. Explain Keywords With Example.?
Answer :
Keywords are those words that are reserved to be used for a specific task. These words cannot be used as identifiers. You cannot use a keyword to define the name of a variable or method. Keywords are used in programs to use the features of object-oriented programming.
For example, the abstract keyword is used to implement abstraction and the inherits keyword is used to implement inheritance by deriving subclasses in C# and Visual Basic, respectively.
The new keyword is universally used in C# and Visual Basic to implement encapsulation by creating objects.
Question 8. Give The Syntax Of Using The For Loop In C# Code?
Answer :
The syntax of using the for loop in C# code is given as follows:
for(initializer; condition; loop expression)
{
//statements
}
In the preceding syntax, initializer is the initial value of the variable, condition is the expression that is checked before the execution of the for loop, and loop expression either increments or decrements the loop counter.
The example of using the for loop in C# is shown in the following code snippet:
for(int i = 0; i < 5; i++)
Console.WriteLine("Hello");
In the preceding code snippet, the word Hello will be displayed for five times in the output window.
Question 9. Give The Syntax Of Using The While Loop In A C# Program.?
Answer :
The syntax of using the while loop in C# is:
while(condition) //condition
{
//statements
}
You can find an example of using the while loop in C#:
int i = 0;
while(i < 5)
{
Console.WriteLine("{0} ", i);
i++;
}
The output of the preceding code is: 0 1 2 3 4 .
Answer :
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;
Console.WriteLine(w);
/* The output of the code is 504. */
Question 11. What Are The Different Types Of Literals?
Answer :
A literal is a textual representation of a particular value of a type.
The different types of literals in Visual Basic are:
The different types of literals in C# are:
Question 12. What Does A Break Statement Do In The Switch Statement?
Answer :
The switch statement is a selection control statement that is used to handle multiple choices and transfer control to the case statements within its body.
The following code snippet shows an example of the use of the switch statement in C#:
switch(choice)
{
case 1:
console.WriteLine("First");
break;
case 2:
console.WriteLine("Second");
break;
default:
console.WriteLine("Wrong choice");
break;
}
In switch statements, the break statement is used at the end of a case statement. The break statement is mandatory in C# and it avoids the fall through of one case statement to another.
Question 13. What Is A Data Type? How Many Types Of Data Types Are There In .net ?
Answer :
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.
Question 14. What Is A Parameter? Explain The New Types Of Parameters Introduced In C# 4.0.?
Answer :
A parameter is a special kind of variable, which is used in a function to provide a piece of information or input to a caller function. These inputs are called arguments.
In C#, the different types of parameters are as follows:
The example of optional parameter is as follows:
public int Sum(int a, int b, int c = 0, int d = 0); /* c and d is optional */
Sum(10, 20); //10 + 20 + 0 + 0
Sum(10, 20, 30); //10 + 20 + 30 + 0
Sum(10, 20, 30, 40); //10 + 20 + 30 + 40
• Named parameter - Refers to the new parameter introduced in C# 4.0. Now you can provide arguments by name rather than position.
The example of the named parameter is as follows:
public void CreateAccount(string name, string address = "unknown", int age = 0);
CreateAccount("Sara", age: 30);
CreateAccount(address: "India", name: "Sara");
Question 15. What Is An Identifier?
Answer :
Identifiers are northing but names given to various entities uniquely identified in a program. The name of identifiers must differ in spelling or casing. For example, MyProg and myProg are two different identifiers. Programming languages, such as C# and Visual Basic, strictly restrict the programmers from using any keyword as identifiers. Programmers cannot develop a class whose name is public, because, public is a keyword used to specify the accessibility of data in programs.
Answer :
Constants perform the same tasks as read-only variables with some differences. The differences between constants and read-only are
Constants:
Read-only:
Question 17. What Is The Main Difference Between Sub-procedure And Function?
Answer :
The sub-procedure is a block of multiple visual basic statements within Sub and End Sub statements. It is used to perform certain tasks, such as changing properties of objects, receiving or processing data, and displaying an output. You can define a sub-procedure anywhere in a program, such as in modules, structures, and classes.
We can also provide arguments in a sub-procedure; however, it does not return a new value.
The function is also a set of statements within the Function and End Function statements. It is similar to sub-procedure and performs the same task. The main difference between a function and a sub-procedure is that sub-procedures do not return a value while functions do.
Question 18. What Is The Syntax To Declare A Namespace In .net?
Answer :
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
Question 19. Which Statement Is Used To Replace Multiple If-else Statements In Code.?
Answer :
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.
Dot-Net Developer Related Tutorials |
|
---|---|
VB.NET Tutorial | C#. NET Tutorial |
ASP.NET Tutorial |
Dot-Net Developer Related Interview Questions |
|
---|---|
VB.NET Interview Questions | C#. NET Interview Questions |
ASP.NET Interview Questions | ADO.Net Interview Questions |
Dot-Net Developer Related Practice Tests |
|
---|---|
VB.NET Practice Tests | C#. NET Practice Tests |
ASP.NET Practice Tests | ADO.Net Practice Tests |
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.