1. If A.equals(B) is true then A.getHashcode & B.getHashCode must always return same hash code.
The answer is False because it is given that A.equals(B) returns true i.e. objects are equal and now its hashCode is asked which is always independent of the fact that whether objects are equal or not. So, GetHashCode for both of the objects returns different value.
2. What is an indexer in C#?
Indexer is a special syntax for overloading [] operator for a class. After defining an indexer, array syntaxes can be used for the class objects.
3. What is the use of fixed statement?
The fixed statement sets a pointer to a managed variable and “pins” that variable during the execution of statement.
Without fixed, pointers to managed variables would be of little use since garbage collection could relocate the variables unpredictably. (In fact, the C# compiler will not allow you to set a pointer to a managed variable except in a fixed statement.)
Eg:
Class A { public int i; }
A objA = new A; // A is a .net managed type
fixed(int *pt = &objA.i) // use fixed while using pointers with managed
// variables
{
*pt=45; // in this block use the pointer the way u want
}
4. What is the order of destructors called in a polymorphism hierarchy?
Destructors are called in reverse order of constructors. First destructor of most derived class is called followed by its parent’s destructor and so on till the topmost class in the hierarchy.
You don’t have control over when the first destructor will be called, since it is determined by the garbage collector. Sometime after the object goes out of scope GC calls the destructor, then its parent’s destructor and so on.
When a program terminates definitely all object’s destructors are called.
5. How can you sort the elements of the array in descending order?
int[] arr = new int[3];
arr[0] = 4;
arr[1] = 1;
arr[2] = 5;
Array.Sort(arr);
Array.Reverse(arr);
6. Is it possible to Override Private Virtual methods.
No, First of all you cannot declare a method as ‘private virtual’.
7. What is the difference between shadow and override?
Overriding is used to redefines only the methods, but shadowing redefines the entire element.
8. Is it possible to debug the classes written in other .Net languages in a C# project.
It is definitely possible to debug other .Net languages code in a C# project. As everyone knows .net can combine code written in several .net languages into one single assembly. Same is true with debugging.
9. What is the syntax to inherit from a class in C#?
Place a colon and then the name of the base class.
Example: class NewClassName : BaseClassName
10. Describe the accessibility modifier “protected internal”.
It is available to classes that are within the same assembly and derived from the specified base class.
11. What is a satellite Assembly?
An assembly containing localized resources for another assembly.
12. How to declares a two-dimensional array in C#?
Syntax for Two Dimensional Array in C Sharp is int[,] ArrayName;
13. What does it meant to say “the canonical” form of XML?
The purpose of Canonical XML is to define a standard format for an XML document. Canonical XML is a very strict XML syntax, which lets documents in canonical XML be compared directly.
Using this strict syntax makes it easier to see whether two XML documents are the same. For example, a section of text in one document might read Black & White, whereas the same section of text might read Black & White in another document, and even in another. If you compare those three documents byte by byte, they’ll be different. But if you write them all in canonical XML, which specifies every aspect of the syntax you can use, these three documents would all have the same version of this text (which would be Black & White) and could be compared without problem. This Comparison is especially critical when xml documents are digitally signed. The digital signal may be interpreted in different way and the document may be rejected.
14. What are Delegates?
Delegates are just like function pointers in C++, except that they are much safer to use due to their type safety. A delegate defines a function without implementing it and another class then provides the implementation. Events in C# are based on delegates, with the originator defining one or more callback functions.
15. What is C#?
C# ( pronounced as C-sharp ) is a new Java like language from Microsoft. Microsoft says that C# is a language with the power of C++ and simplicity of Visual Basic. C# supposed to be the best language for Microsoft’s .NET programming.
16. What is 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.
17. Why do one get a syntax error when trying to declare a variable called checked?
Syntax Error is thrown because the word checked is a keyword in C#.
18. If a method is marked as protected internal how can it be accessed?
Method marked as Protected internally can be accessed by the Classes within the same assembly, and classes derived from the declaring class.
19. What is boxing?
Encapsulating a copy of a value type in an object.
20. How can I make sure my C# classes will interoperate with other .NET languages?
Make sure your C# code conforms to the Common Language Subset (CLS). To help with this, add the [assembly:CLSCompliant(true)] global attribute to your C# source files. The compiler will emit an error if you use a C# feature which is not CLS-compliant.
Comma separated values in SQL Server
13 years ago
No comments:
Post a Comment