Govt. Exams
Entrance Exams
C# allows comparison between int and double. 5 and 5.0 are numerically equal, so == returns True.
protected members are accessible from the same class and derived classes, but not from outside the class hierarchy.
Abstract classes can contain both abstract and non-abstract (concrete) methods and properties. They cannot be instantiated directly.
x++ is post-increment, so it returns the current value (5) before incrementing. The next Console.WriteLine would print 6.
Accessing array elements beyond bounds throws IndexOutOfRangeException at runtime.
var is implicitly typed, meaning the compiler infers the type at compile time, but it's still strongly typed. It's not dynamic.
readonly keyword prevents reassignment of a field after initialization. const is for compile-time constants, static for class-level, sealed for inheritance prevention.
Accessing an array element beyond its bounds throws an IndexOutOfRangeException at runtime. This is a safety feature to prevent accessing invalid memory.
'sealed' keyword prevents a class from being inherited in C#. 'final' is Java syntax. 'abstract' requires a class to be inherited. 'static' makes members class-level, not related to inheritance.
bool result = (5 > 3) && (2 < 1);
Console.WriteLine(result);
(5 > 3) is true, but (2 < 1) is false. The '&&' (AND) operator returns true only if both conditions are true. Since one is false, the result is false.