[go: up one dir, main page]

0% found this document useful (0 votes)
21 views8 pages

DotNet SQL 100 QA

Uploaded by

ravimullick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views8 pages

DotNet SQL 100 QA

Uploaded by

ravimullick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

100 .

NET & SQL Interview Questions and Answers

Q1. What are the four pillars of OOP?


A: Encapsulation, Abstraction, Inheritance, Polymorphism.

Q2. Explain Encapsulation.


A: Binding data and methods into a single unit (class).

Q3. What is Abstraction?


A: Showing only essential details while hiding implementation.

Q4. What is Inheritance?


A: Ability of a class to acquire properties of another class.

Q5. What is Polymorphism?


A: Ability of a method to take multiple forms (compile-time, runtime).

Q6. What are SOLID principles?


A: SRP, OCP, LSP, ISP, DIP – guidelines for maintainable software.

Q7. Explain Open/Closed Principle.


A: Classes should be open for extension, closed for modification.

Q8. What is Liskov Substitution Principle?


A: Subtypes should be replaceable for their base types without altering correctness.

Q9. What is Interface Segregation?


A: Clients should not be forced to depend on methods they don’t use.

Q10. What is Dependency Inversion?


A: High-level modules should depend on abstractions, not details.

Q11. What is Singleton Pattern?


A: Ensures a class has only one instance and provides a global access point.

Q12. Explain Factory Pattern.


A: Provides a way to create objects without exposing creation logic.

Q13. Explain Repository Pattern.


A: Abstraction over data layer for cleaner separation of concerns.

Q14. Difference between .NET Framework and .NET Core?


A: .NET Framework is Windows-only, .NET Core is cross-platform.

Q15. What is CLR?


A: Common Language Runtime – manages code execution in .NET.

Q16. What is CTS?


A: Common Type System – defines how types are declared and used.

Q17. What is CLS?


A: Common Language Specification – ensures interoperability among .NET languages.

Q18. What is Garbage Collection?


A: Automatic memory management that reclaims unused objects.

Q19. What is JIT Compiler?


A: Just-In-Time compiler compiles IL code to native code at runtime.

Q20. Explain Delegates.


A: Type-safe function pointers used for callbacks and event handling.

Q21. What are Events?


A: Special delegates used for publisher-subscriber model.

Q22. What is LINQ?


A: Language Integrated Query for querying collections, databases, XML.

Q23. Difference between IEnumerable and IQueryable?


A: IEnumerable executes queries in memory, IQueryable executes at database/server side.

Q24. What are Extension Methods?


A: Static methods that extend existing types without modifying them.

Q25. What are Generics?


A: Allow type safety and code reusability without boxing/unboxing.

Q26. What is Dependency Injection?


A: Providing dependencies from outside the class instead of creating inside.
Q27. Types of Dependency Injection?
A: Constructor, Property, Method Injection.

Q28. What is IoC Container?


A: Framework for managing dependencies (Autofac, Unity, built-in DI in .NET Core).

Q29. What is Entity Framework?


A: ORM that maps database tables to .NET objects.

Q30. Difference between Code First and Database First in EF?


A: Code First starts with classes, Database First starts with schema.

Q31. What is Lazy Loading?


A: Data is loaded on demand when accessed.

Q32. What is Eager Loading?


A: Data is preloaded with main query using Include().

Q33. What is Explicit Loading?


A: Manually loading related entities using Load() method.

Q34. What are EF migrations?


A: Way to evolve database schema along with model changes.

Q35. How do you optimize performance in .NET?


A: Use caching, async/await, minimize boxing, optimize LINQ queries.

Q36. What are Value types vs Reference types?


A: Value types store data directly, Reference types store references.

Q37. Difference between Struct and Class?


A: Struct is value type, lightweight; Class is reference type, supports inheritance.

Q38. What is Boxing and Unboxing?


A: Boxing: converting value type to object; Unboxing: reverse.

Q39. What are Async/Await?


A: Keywords for asynchronous programming with tasks.

Q40. What is Task vs Thread?


A: Task represents async operations, Thread is OS-level execution unit.
Q41. How do you secure APIs?
A: Use HTTPS, JWT, OAuth2, API keys, role-based authorization.

Q42. What is OAuth2?


A: Authorization protocol for delegated access without sharing credentials.

Q43. What is JWT?


A: JSON Web Token used for securely transmitting claims between parties.

Q44. What is CORS?


A: Cross-Origin Resource Sharing – allows APIs to be accessed from different domains.

Q45. What is DevOps?


A: Culture/practice for continuous integration, delivery, and deployment.

Q46. How do you deploy .NET Core app to IIS?


A: Publish → Install Hosting Bundle → Configure IIS site → Point to folder.

Q47. What is CI/CD?


A: Continuous Integration/Delivery – automate builds, tests, and deployments.

Q48. What logging frameworks are used?


A: Serilog, NLog, log4net, Microsoft.Extensions.Logging.

Q49. What is Application Insights?


A: Azure service for monitoring performance, usage, failures.

Q50. How do you handle errors in .NET?


A: Try/catch, global exception handling middleware, logging frameworks.

Q51. What is a Primary Key?


A: A column or set of columns that uniquely identifies a row.

Q52. What is a Foreign Key?


A: A column that creates a relationship between two tables.

Q53. What is a Unique Key?


A: Ensures all values in a column are distinct but allows one NULL.

Q54. What is a Composite Key?


A: A key made up of multiple columns.

Q55. Difference between Stored Procedure and Function?


A: SP can return multiple values, Function must return single value.

Q56. What is Referential Integrity?


A: Maintaining consistency across tables using foreign keys.

Q57. What is a View?


A: Virtual table based on result of SQL query.

Q58. What is an Index?


A: Database object to speed up data retrieval.

Q59. Difference between Clustered and Non-Clustered Index?


A: Clustered defines physical order of data, Non-clustered is separate structure with pointer.

Q60. What are disadvantages of indexes?


A: Extra storage, slower writes (insert/update/delete).

Q61. What are Joins?


A: Combining data from multiple tables based on relationships.

Q62. Explain INNER JOIN.


A: Returns only matching rows from both tables.

Q63. Explain LEFT JOIN.


A: Returns all rows from left table and matching from right.

Q64. Explain RIGHT JOIN.


A: Returns all rows from right table and matching from left.

Q65. Explain FULL OUTER JOIN.


A: Returns all rows from both tables, with NULLs where no match.

Q66. Difference between UNION and UNION ALL?


A: UNION removes duplicates, UNION ALL keeps all records.

Q67. What is a Subquery?


A: Query within another query.
Q68. Difference between Correlated and Non-Correlated Subquery?
A: Correlated depends on outer query, Non-correlated executes independently.

Q69. What is a CTE?


A: Common Table Expression – temporary result set for queries.

Q70. What are Window Functions?


A: Functions like ROW_NUMBER, RANK, PARTITION for analytics.

Q71. How do you optimize SQL queries?


A: Indexes, avoid SELECT *, use EXISTS, analyze execution plan.

Q72. What is Execution Plan?


A: Shows how SQL Server executes a query, helps in tuning.

Q73. Difference between DELETE and TRUNCATE?


A: DELETE removes rows with condition, TRUNCATE removes all rows faster.

Q74. Difference between DROP and TRUNCATE?


A: DROP removes table structure, TRUNCATE removes only data.

Q75. What is Normalization?


A: Process of organizing DB to reduce redundancy.

Q76. Explain 1NF, 2NF, 3NF.


A: 1NF: Atomic values, 2NF: No partial dependency, 3NF: No transitive dependency.

Q77. What is Denormalization?


A: Adding redundancy for faster reads.

Q78. What is ACID property?


A: Atomicity, Consistency, Isolation, Durability in transactions.

Q79. What is a Transaction?


A: Sequence of operations performed as a single logical unit of work.

Q80. Difference between Commit and Rollback?


A: Commit saves changes, Rollback undoes them.

Q81. What is Deadlock?


A: Two processes waiting for each other’s locks, causing halt.
Q82. How to resolve Deadlocks?
A: Use shorter transactions, consistent locking order, avoid unnecessary locks.

Q83. What is Isolation Level?


A: Defines how transaction integrity is visible to other transactions.

Q84. Difference between Read Committed and Repeatable Read?


A: Read Committed allows non-repeatable reads, Repeatable Read prevents it.

Q85. What is Serializable Isolation?


A: Highest level – prevents phantom reads.

Q86. What are Triggers?


A: Procedures that execute automatically in response to events.

Q87. Difference between AFTER and INSTEAD OF Trigger?


A: AFTER fires after operation, INSTEAD OF replaces it.

Q88. What is a Cursor?


A: Allows row-by-row processing of result sets.

Q89. When to avoid Cursors?


A: When set-based operations can be used, as cursors are slow.

Q90. What are Stored Procedures?


A: Precompiled SQL statements that improve performance and reusability.

Q91. Advantages of Stored Procedures?


A: Better performance, security, reusability, modularity.

Q92. What are Functions?


A: Return a single value, can be used in queries.

Q93. Difference between Scalar and Table-Valued Function?


A: Scalar returns single value, Table-Valued returns table.

Q94. What are Linked Servers?


A: Allow SQL Server to query remote databases.

Q95. What is Database Migration?


A: Process of moving schema/data from one DB to another.

Q96. How do you handle User Access Control?


A: Granting roles, privileges, using GRANT, REVOKE, DENY.

Q97. What is SQL Injection?


A: Attack by injecting malicious SQL code into queries.

Q98. How do you prevent SQL Injection?


A: Use parameterized queries, stored procedures, ORM frameworks.

You might also like