Posts Tagged ‘.NET’
Interview Questions (.NET)
-
What’s the difference of using System.Text.StringBuilder over System.String?
Answer: System.String is immutable. System.StringBuilder was designed with the
purpose of having a mutable string where a variety of operations can be performed. -
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
Answer: The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements
into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element’s object, resulting in a different, yet identical object. -
How can you sort the elements of the array in descending order?
Answer: By calling Sort () and then Reverse () methods. -
What’s the .NET collection class that allows an element to be accessed using a unique key?
Answer: Hashtable.
Interview Questions (.NET)
-
What’s the difference of using System.Text.StringBuilder over System.String?
Answer: System.String is immutable. System.StringBuilder was designed with the
purpose of having a mutable string where a variety of operations can be performed. -
What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
Answer: The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements
into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element’s object, resulting in a different, yet identical object. -
How can you sort the elements of the array in descending order?
Answer: By calling Sort () and then Reverse () methods. -
What’s the .NET collection class that allows an element to be accessed using a unique key?
Answer: Hashtable. -
Can you allow a class to be inherited, but prevent the method from being over-ridden?
Answer: Yes. Just leave the class public and make the method sealed. -
When do you absolutely have to declare a class as abstract?
Answer:
-
When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
-
When at least one of the methods in the class is abstract.
-
-
What accessibility modifier for methods you may specify inside the interface?
Answer: They all must be public, and are therefore public by default. -
What’s the implicit name of the parameter that gets passed into the set method/property of a class?
Answer: Value. The data type of the value parameter is defined by whatever data type the property is declared as. -
What’s the difference between // comments, /* */ comments and /// comments?
Answer: // is single-line comment, /**/ is multi-line comment & /// is document comment -
What is CorDBG and what is DbgCLR?
Answer: Cordbg is a runtime debugger. -
What does assert() method do?
Answer: In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true. -
What’s the difference between the Debug class and Trace class?
Answer: Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds. -
What happens if you inherit multiple interfaces and they have conflicting method names?
Answer: It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. You have to provide interfacename.methodname.
OO Questions for .NET/Java
-
To which is protected class-level variable available to?
Answer: It is available to any sub-class (a class inheriting this class). -
Are private class-levl variables inherited?
Answer: Yes, but those are not accessible. Although those are not visible or accessible via the class interface, yet those are inherited. -
Describe the accessiblilty modifier "protected internal"?
Answer: It is available to classes that are within the same assembly and derived from specific base class.