Govt. Exams
Entrance Exams
Overloading creates multiple methods with the same name but different parameters. Overriding replaces a base class method in a derived class.
The 'init' accessor (introduced in C# 9) allows setting the property only during initialization. Any modification attempt post-initialization causes a compile-time error.
C# 11 introduced the 'required' keyword that enforces callers to initialize specific members during object instantiation.
C# auto-properties with 'init' accessor allow creating read-only properties that can only be set during initialization, improving encapsulation.
Constructor chaining uses 'this()' to call another constructor in the same class. Option B shows proper syntax for calling a parameterless constructor.
Classes are reference types stored on heap, structs are value types stored on stack. This affects memory management and behavior.
The 'sealed' keyword prevents a class from being inherited or a method from being overridden in derived classes.
Properties in C# allow controlled access to fields with validation logic while maintaining clean, intuitive syntax like field access.
IEnumerable interface in C# is used to provide iteration capability through the GetEnumerator() method.
'new' keyword hides the base class method (method hiding), while 'override' provides true polymorphic behavior by replacing the method.