.Net Framework Interview Questions 8

By | May 13, 2014

What is JIT and how is works ? An acronym for “just-in-time,” a phrase that describes an action that is taken only when it becomes necessary, such as just-in-time compilation or just-in-time object activation

What is portable executable (PE) ? The file format used for executable programs and for files to be linked together to form executable programs

What is strong name? A name that consists of an assembly’s identity—its simple text name, version number, and culture information (if provided)—strengthened by a public key and a digital signature generated over the assembly. Because the assembly manifest contains file hashes for all the files that constitute the assembly implementation, it is sufficient to generate the digital signature over just the one file in the assembly that contains the assembly manifest. Assemblies with the same strong name are expected to be identical

What is global assembly cache? A machine-wide code cache that stores assemblies specifically installed to be shared by many applications on the computer. Applications deployed in the global assembly cache must have a strong name.

What is difference between constants, readonly and, static ? Constants: The value can’t be changed Read-only: The value will be initialized only once from the constructor of the class. Static: Value can be initialized once.

What is difference between shared and public? An assembly that can be referenced by more than one application. An assembly must be explicitly built to be shared by giving it a cryptographically strong name.

What is namespace used for loading assemblies at run time and name the methods? System.Reflection

What are the types of authentication in .net? We have three types of  authentication: 1. Form authentication 2.  Windows authentication 3.  Passport This has to be declared in web.config file.

What is the difference between a Struct and a Class ? The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects, you will allocate additional memory for referencing each object. In this case, the struct is less expensive. When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized. It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values. It is an error to initialize an instance field in a struct. There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do. A struct is a value type, while a class is a reference type.

How big is the datatype int in .NET? 32 bits.

How big is the char? 16 bits (Unicode).

How do you initiate a string without escaping each backslash? Put an @ sign in front of the double-quoted string.

What’s the access level of the visibility type internal? Current application. Explain encapsulation ? The implementation is hidden, the interface is exposed.

What data type should you use if you want an 8-bit value that’s signed? sbyte.

Speaking of Boolean data types, what’s different between C# and C/C++? There’s no conversion between 0 and false, as well as any other number and true, like in C/C++.

Where are the value-type variables allocated in the computer RAM? Stack.

Where do the reference-type variables go in the RAM? The references go on the stack, while the objects themselves go on the heap.

What is the difference between the value-type variables and reference-type variables in terms of garbage collection? The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null.

How do you convert a string into an integer in .NET? Int32.Parse(string)

How do you box a primitive data type variable? Assign it to the object, pass an object.

Why do you need to box a primitive variable? To pass it by reference.

What’s the difference between Java and .NET garbage collectors? Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE you’re using. Microsoft standardized on their garbage collection.

How do you enforce garbage collection in .NET? System.GC.Collect();

What’s different about namespace declaration when comparing that to package declaration in Java? No semicolon.

What’s the difference between const and readonly? You can initialize readonly variables to some runtime values. Let’s say your program uses current date and time as one of the values that won’t change. This way you declare public readonly string DateT = new DateTime().ToString().

What happens when you encounter a continue statement inside the for loop? The code for the rest of the loop is ignored, the control is transferred back to the beginning of the loop.

What’s the advantage of using System.Text.StringBuilder over System.String? StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.

Can you store multiple data types in System.Array? No.

What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? The first one performs a deep copy of the array, the second one is shallow.

How can you sort the elements of the array in descending order? By calling Sort() and then Reverse() methods.

What’s the .NET datatype that allows the retrieval of data by a unique key? HashTable.

What’s class SortedList underneath? A sorted HashTable.

Will finally block get executed if the exception had not occurred? Yes.

Can multiple catch blocks be executed? No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.

Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.

What’s a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.

What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods.

How’s the DLL Hell problem solved in .NET? Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32),  but also the version of the assembly.

What are the ways to deploy an assembly?  An MSI installer, a CAB archive, and XCOPY command.

What’s a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

What namespaces are necessary to create a localized application? System.Globalization, System.Resources

Leave a Reply