Govt. Exams
Entrance Exams
public class Animal { public virtual void Sound() { Console.WriteLine("Some sound"); } }
public class Dog : Animal { public override void Sound() { Console.WriteLine("Bark"); } }
Animal animal = new Dog();
animal.Sound();
Due to polymorphism, the overridden method in Dog class is called at runtime, printing 'Bark' even though the reference type is Animal.
Static variables are shared across all instances and can be used to generate unique IDs automatically without modifying external data.
Virtual methods are designed to be overridden by derived classes, enabling polymorphic behavior and runtime method resolution.
Polymorphism through inheritance allows each vehicle type to override the toll calculation method with its own implementation, enabling different behavior for each type.
sealed prevents a class from being inherited, while abstract requires derived classes to implement its abstract members. They serve opposite purposes.
Inheritance allows creating a base class (LibraryItem) with common properties, and derived classes can inherit these properties, reducing code duplication.
Entity Framework is Microsoft's ORM that allows developers to work with databases using .NET objects instead of raw SQL.
ViewBag (dynamic) and ViewData (dictionary) are common ways to pass data from Controller to View in ASP.NET MVC.
[ValidateAntiForgeryToken] verifies that form submissions come from your application, preventing CSRF attacks.
Dependency Injection is configured in the ConfigureServices method of Startup.cs (or Program.cs in newer versions).