Govt. Exams
Entrance Exams
Covariance (using 'out' keyword) allows a more derived type to be returned where a base type is expected, improving type safety and flexibility.
Derived classes must call base.Dispose() to ensure proper cleanup of base class resources, following the disposable pattern correctly.
'sealed override' prevents further overriding of an already overridden virtual method in derived-from-derived classes.
The 'file' access modifier (C# 11+) restricts type visibility to the file it's declared in, improving encapsulation at the file level.
Due to method overriding and polymorphism, C's Display() executes if overridden. Otherwise, the most derived available implementation in the inheritance chain executes.
Creating an IPayment interface with different payment classes implementing it demonstrates polymorphism, allowing the system to handle various payment methods uniformly.
The proper Dispose pattern implements IDisposable and uses a finalizer/destructor as a safety net, following the recommended pattern in C#.
C# 12 allows field initializers directly in struct declarations, enabling parameterless constructors with initialized default values.
C# 8 introduced default interface implementations, allowing interfaces to have method bodies that implementing classes can inherit or override.
The 'file' scoped type modifier (C# 11) restricts a type to be visible only within the file it's declared in, preventing accidental public API expansion.