Govt. Exams
Entrance Exams
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.
In C#, 'int?' is used to declare a nullable integer. A regular 'int' cannot be assigned null. int* is a pointer (unsafe code), not a nullable type.
int.Parse() converts a string to an integer. Direct casting doesn't work for strings. Convert.ToInt32() would throw an exception if the string is not a valid number. The 'as' operator doesn't work for strings to primitives.