1. What is .NET Framework?
Answer:
.NET Framework is a Microsoft software development platform used to build Windows, Web, and Enterprise applications. It includes:
-
CLR (Common Language Runtime)
-
BCL (Base Class Library)
-
Languages: C#, VB.NET, F#
-
Tools: Visual Studio
It allows cross-language interoperability and simplifies memory management via the CLR.
2. What is .NET Core / .NET 5+?
Answer:
.NET Core (now unified under .NET 5, .NET 6, .NET 7, .NET 8) is:
-
Cross-platform (Windows, Linux, macOS)
-
Open-source
-
High-performance and lightweight
-
Supports microservices, containers, and cloud-native apps
It replaced the old .NET Framework with a unified modern platform.
3. What is the CLR?
Answer:
CLR (Common Language Runtime) is the runtime environment of .NET.
It handles:
-
Memory management
-
Garbage Collection
-
Thread management
-
Exception handling
-
Code execution
-
Security
It converts MSIL (Microsoft Intermediate Language) into native machine code.
4. What is the difference between .NET Framework and .NET Core?
Answer:
| Feature | .NET Framework | .NET Core/.NET 6+ |
|---|---|---|
| Platform | Windows-only | Cross-platform |
| Open Source | Limited | Fully open-source |
| Performance | Moderate | High-performance |
| Deployment | System-level | Side-by-side |
| Architecture | Monolithic | Modular |
.NET Core is recommended for modern applications, cloud applications, and microservices.
5. What is C#?
Answer:
C# (C Sharp) is an object-oriented programming language developed by Microsoft.
Features:
-
Strongly typed
-
OOP-based
-
Garbage-collected
-
Supports LINQ, async/await, generics
-
Used for web, desktop, API, game development (Unity), cloud apps.
6. What is MSIL/IL Code?
Answer:
MSIL (or IL) is the intermediate code generated after compiling C# code.
CLR converts IL to native code using JIT (Just-In-Time) compiler.
7. What is JIT Compiler?
Answer:
JIT Compiler converts MSIL into machine code during program execution.
Types of JIT:
-
Pre-JIT
-
Econo-JIT
-
Normal JIT
This improves performance and optimizes based on runtime.
8. What is OOPS in C#?
Answer:
OOPS stands for:
-
Encapsulation
-
Abstraction
-
Inheritance
-
Polymorphism
It helps create modular, maintainable, and reusable code.
9. Explain Encapsulation with example.
Answer:
Encapsulation hides internal object details and exposes only required functionality.
Example:
Here, balance is protected from direct access.
10. What is Inheritance in C#?
Answer:
Inheritance allows one class to inherit properties and methods of another.
Example:
BMW inherits Drive().
11. What is Polymorphism?
Answer:
Polymorphism allows methods to behave differently based on runtime objects.
Example:
12. Difference between Abstract Class and Interface.
Answer:
| Abstract Class | Interface |
|---|---|
| Can have fields | No fields |
| Can have constructors | No constructors |
| Supports abstract + concrete methods | Only abstract methods |
| Single inheritance only | Multiple inheritance |
13. What are Value Types and Reference Types?
Answer:
-
Value types: stored in stack → int, double, struct
-
Reference types: stored in heap → class, array, string
14. What is Boxing and Unboxing?
Answer:
Boxing: Converting value type → object (heap)
Unboxing: Converting object → value type
Example:
15. What is ASP.NET Core?
Answer:
A high-performance, cross-platform framework for building:
-
Web apps
-
REST APIs
-
Microservices
-
Cloud applications
Uses Middleware and Dependency Injection by default.
16. What are Middleware components?
Answer:
Middleware is a pipeline that handles HTTP requests in sequence.
Examples:
-
Authentication
-
Routing
-
Exception handling
-
Logging
Implemented like:
17. What is Dependency Injection (DI)?
Answer:
A design pattern where dependencies are injected instead of being created inside classes.
Example:
Benefits:
-
Testability
-
Loose coupling
-
Readability
18. What is Entity Framework Core?
Answer:
EF Core is an ORM (Object Relational Mapper) for .NET used to interact with databases using C# instead of SQL.
Features:
-
Migrations
-
LINQ queries
-
Change tracking
-
Database-first & Code-first support
19. What is Code-First approach?
You create C# classes → EF creates database tables automatically.
20. What is Database-First approach?
Database already exists → EF generates models and DbContext.
21. What is Migration in EF Core?
Answer:
Migrations track database schema changes.
Commands:
22. What is LINQ?
Answer:
Language Integrated Query to perform queries on objects, collections, datasets, and DB.
Example:
23. What is async and await?
Answer:
Used for asynchronous programming to avoid thread blocking.
Example:
24. What is Garbage Collection in .NET?
Answer:
Automatic memory management that frees unused objects.
Generations:
-
Gen 0
-
Gen 1
-
Gen 2
25. What is IDisposable Interface?
Used to release unmanaged resources manually.
Example:
26. What is a Constructor and Destructor?
Constructor → initializes object
Destructor → frees resources (rare in .NET)
27. What is Singleton Pattern?
Ensures only one instance of a class exists.
Example:
28. What is Routing in ASP.NET Core?
Matches incoming HTTP requests to endpoints.
Example:
29. What is Model Binding?
ASP.NET Core automatically maps request data to parameters or models.
30. What is ViewModel?
A DTO used between View and Controller to avoid exposing domain models.
31. What is REST API?
Architectural style for building stateless, resource-based web services.
32. Difference between GET and POST.
GET → Fetch data (idempotent)
POST → Create data (not idempotent)
33. What is JWT Token?
A secure token used for authentication between client and server.
Parts:
-
Header
-
Payload
-
Signature
34. What is Swagger?
API documentation and testing tool built on OpenAPI specification.
35. What is Microservices Architecture?
Application broken into independent services.
Benefits: scalability, fault isolation, cloud readiness.
36. What is Kestrel?
The built-in high-performance web server in ASP.NET Core.
37. What is Configuration in ASP.NET Core?
Manages app settings using:
-
appsettings.json
-
Environment variables
-
Azure Key Vault
38. What is CORS?
Cross-Origin Resource Sharing → Allows frontend apps to access APIs from other domains.
39. What is a NuGet Package?
Dependency manager for .NET libraries.
40. What is .NET Standard?
A versioned set of APIs available across all .NET platforms.
41. Explain Sealed Class.
Cannot be inherited, used for security/performance.
42. What is a Partial Class?
A class split into multiple files.
43. What is Reflection?
Inspecting metadata during runtime.
44. What is ADO.NET?
Low-level data access using:
-
SqlConnection
-
SqlCommand
-
SqlDataReader
45. What is Thread and Task in .NET?
Thread → independent execution path
Task → lightweight wrapper for async operations
46. Explain SOLID Principles.
5 design principles for maintainable code:
-
Single Responsibility
-
Open Closed
-
Liskov Substitution
-
Interface Segregation
-
Dependency Inversion
47. What is Attribute in C#?
Metadata added to classes or methods.
Example:
48. What is Filter in ASP.NET Core?
Executes logic before or after controller actions.
Types:
-
Authorization
-
Resource
-
Action
-
Exception
49. What is Web API Versioning?
Manage multiple versions of APIs for backward compatibility.
50. What is Health Check in ASP.NET Core?
Used to monitor the health of application and services in production.
No comments:
Post a Comment