Govt. Exams
Entrance Exams
Post-increment (x++) returns the current value before incrementing. So y = 10, then x becomes 11. Output is '11, 10'.
Method overloading requires same method name but different parameter types, count, or order. Return type alone is insufficient for overloading.
The null-coalescing operator (??) returns the right operand if the left is null. Since text is null, it prints 'Default'.
The 'using' statement ensures that Dispose() is called on objects implementing IDisposable, preventing resource leaks. Importing namespaces is a different use of 'using'.
Method overloading allows same method name with different signatures (parameter types, count, or order). Return type alone cannot differentiate overloaded methods.
Value types (struct) are allocated on the stack, while reference types (class) are allocated on the heap.
Array.Resize() creates a new array of specified size and copies elements from the original array using the ref parameter.
C# has float (4 bytes) and double (8 bytes), but not float32. sbyte, uint, and decimal are valid types.
In C#, structs are value types (stored on stack) while classes are reference types (stored on heap). This is a fundamental difference between the two.
int x = 10;
int y = 20;
int z = x++ + ++y;
Console.WriteLine(x + " " + y + " " + z);
x++ returns 10 then increments x to 11. ++y increments y to 21 then returns 21. z = 10 + 21 = 31. Final output: 11 21 31