Followers

July 18, 2009

C# Concepts,Interview Questions and Answers

C#.NET Interview Questions and Answers,Microsoft C#.NET Frequently Asked Questions,C#.NET Concepts,Answers and Solutions.Check it out below

What happens in memory when you Box and Unbox a value-type?
Boxing converts a value-type to a reference-type, thus storing the object on the heap. Unboxing converts a reference-type to a value-type, thus storing the value on the stack.Difference between directcast and ctype.

Answer1 [DirectCast requires the run-time type of an object variable to bethe same as the specified type.The run-time performance ofDirectCast is better than that of CType, if the specified type and the run-time typeof the expression are the same. Ctype works fine if there is a valid conversion defined between the expression and the type. ]

Answer2 [The difference between the two keywords is that CType succeeds as long as there is a valid conversion defined between the expression and the type, whereas DirectCast requires the run-time type of an object variable to be the same as the specified type. If the specified type and the run-time type of the expression are the same, however, the run-time performance of DirectCast is better than that of CType. ]


An example of a ctype and directcast.

In the preceding example, the run-time type of Q is Double. CType succeeds because Double can be converted to Integer, but DirectCast fails because the run-time type of Q is not already Integer
ctype(123.34,integer) - should it throw an error? Why or why not?
Answer1 [It would work fine. As the runtime type of 123.34 would be double, and Double can be converted to Integer. ]

Answer2 [the ctype(123.34,integer) will work fine no errors ]
directcast(123.34,integer) - should it throw an error? Why or why not?
It would throw an InvalidCast exception as the runtime type of 123.34 (double) doesnt match with Integer.

Difference between a sub and a function.
Answer1 [A Sub does not return anything whereas a Function returns something. ]

Answer2 [-A Sub Procedure is a method will not return a value
-A sub procedure will be defined with a “Sub” keyword

Sub ShowName(ByVal myName As String)
Console.WriteLine(”My name is: ” & myName)
End Sub

-A function is a method that will return value(s).
-A function will be defined with a “Function” keyword

Function FindSum(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
Dim sum As Integer = num1 + num2
Return sum
End Function]
Explain manifest & metadata.
Answer1 [Manifest is metadata about assemblies. Metadata is machine-readable information about a resource, or “”data about data.” In .NET, metadata includes type definitions, version information, external assembly references, and other standardized information. ]

Answer2 [Manifest: Manifest describes assembly itself. Assembly Name, version number, culture, strong name, list of all files, Type references, and referenced assemblies.
Metadata: Metadata describes contents in an assembly classes, interfaces, enums, structs, etc., and their containing namespaces, the name of each type, its visibility/scope, its base class, the nterfaces it implemented, its methods and their scope, and each method’s parameters, type’s properties, and so on. ]

Difference between imperative and interrogative code.
There are imperative and interrogative functions. Imperative functions are the one which return a value while the interrogative functions do not return a value.

Difference between value and reference type. what are value types and reference types?
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap

What are the two kinds of properties. Two types of properties in .Net: Get and Set
Explain constructor.
Constructor is a method in the class which has the same name as the class (in VB.Net its New()). It initializes the member attributes whenever an instance of the class is created.
Describe ways of cleaning up objects.

Answer1
[There is a perfect tool provide by .net frameworks calls Garbage collector, where by mean of GC we can clean up the object and reclaim the memory. The namespace used is System.GC ]

Answer2
[the run time will maintain a service called as garbage collector. This service will take care of deallocating memory corresponding to objects. it works as a thread with least priority. when application demands for memory the runtime will take care of setting the high priority for the garbage collector, so that it will be called for execution and memory will be released. the programmer can make a call to garbage collector by using GC class in system name space. ]

How can you clean up objects holding resources from within the code?
Call the dispose method from code for clean up of objects

Which controls do not have events?
Timer control.


What is the maximum size of the textbox?
65536.


Which property of the textbox cannot be changed at runtime?
Locked Property.


Which control cannot be placed in MDI?
The controls that do not have events.

What is the difference between proc. sent BY VAL and BY SUB?
BY VAL: changes will not be reflected back to the variable.
By REF: changes will be reflected back to that variable.( same as & symbol in c, c++)

People who read this, may find the below Interesting

0 comments on "C# Concepts,Interview Questions and Answers"

Share this: Humsurfer| Indianpad|
Digg Google Bookmarks

Post a Comment

 

Aired : Interview Questions | Certifications | Jobs | Walk - In | Results | Career Help | Copyright © 2009-2011