CSharp and OOP
CSharp and OOP
Candidate:Priyal
Date:10/06/2023
C# and OOP
Basic Concepts:
· Explain the difference between value types and reference types in C#.
o Value types store the actual data, while reference types store a reference to the data's memory location.
· What is boxing and unboxing in C#?
o Boxing is the process of converting a value type to a reference type, and unboxing is the reverse.
Object-Oriented Programming (OOP/OOD):
· Describe the principles of object-oriented programming and how they apply to C#.
o The principles include abstraction, encapsulation, inheritance, and polymorphism.
· What is the difference between an abstract class and an interface?
o An abstract class can have implementation, while an interface only defines method signatures.
C# Language Features:
· Explain the "using" statement in C# and its significance.
o Used for resource management, it ensures that the IDisposable object is properly disposed of.
· What is the purpose of the "as" operator in C#?
o Used for explicit type conversion, returning null if the conversion fails.
Exception Handling:
· How does exception handling work in C#? Explain the try, catch, and finally blocks.
o Try block contains the code that might throw an exception, catch block handles the exception, and finally blo
· What is the difference between "throw" and "throw ex" in exception handling?
o "throw" preserves the original stack trace, while "throw ex" replaces it with the current location.
Memory Management:
· How does garbage collection work in C#?
o Automatic process of deallocating memory occupied by objects that are no longer in use.
· Explain the concept of IDisposable and when it's used.
o Interface used for releasing unmanaged resources; often implemented using the Dispose pattern.
Asynchronous Programming:
· What are asynchronous methods in C#? How do they differ from synchronous methods?
o Allow non-blocking execution; "async" keyword signifies an asynchronous method, and "await" is used to wa
· Explain the use of the "async" and "await" keywords.
o When a method is declared with the "async" modifier, it becomes an asynchronous method. An asynchrono
o The "await" expression pauses the execution of the asynchronous method until the awaited task is complete
Delegates and Events:
· What is a delegate, and how is it different from an interface?
o A type that represents references to methods with a specific parameter list and return type.
· How are events implemented in C#?
o Mechanism for communication between objects; often used to implement the observer pattern.
Collections:
· Compare and contrast List<T> and Dictionary<T, U> in C#.
o List<T> is an ordered collection, Dictionary<T, U> is a key-value pair collection.
· Explain the differences between IEnumerable and IQueryable.
o IEnumerable is for in-memory collections, IQueryable is for database queries.
Dependency Injection:
· What is dependency injection, and how is it implemented in C#?
o Pattern where a class receives its dependencies from an external source rather than creating them.
· How does constructor injection differ from property injection?
o Constructor injection passes dependencies through the constructor, while property injection sets them thro
Entity Framework:
· Explain the role of Entity Framework in C# development.
o ORM (Object-Relational Mapping) framework for database interaction in C#.
· What are the different states that an entity can have in Entity Framework?
o Added, Unchanged, Modified, Deleted, Detached - representing the state of an entity in the context.
Unit Testing:
· How do you perform unit testing in C#? Mention some popular testing frameworks.
o Using frameworks like NUnit or MSTest to test individual units of code.
· What is the purpose of the [SetUp] and [TearDown] attributes in unit testing?
o [SetUp] is run before each test, [TearDown] is run after each test for setup and cleanup.
Serialization:
· What is serialization, and how is it implemented in C#?
o Process of converting an object into a format that can be easily stored or transmitted.
· Explain the differences between binary serialization and XML serialization.
o Binary is more compact and faster but less human-readable than XML.
Security:
· How do you secure sensitive information, such as connection strings, in a C# application?
o Use configuration files with restricted access or encryption for sensitive data.
· What are SQL injection attacks, and how can they be prevented in C#?
o Prevented by using parameterized queries or stored procedures.
Design Patterns:
· Name and explain a few design patterns commonly used in C#.
o Examples include Singleton, Pub-Sub, Factory, Façade, Observer, and Strategy patterns.
· What are SOLID design principles? Can you explain Dependency Inversion (DI)?
o SOLID is an acronym that stands for five key design principles: single responsibility principle, open-closed pri
· How does the Singleton pattern work, and when would you use it?
· [What is Singleton class? Why do we need one? Give an example Singleton class that you have used? (If too good to
o Ensures a class has only one instance and provides a global point to that instance.
o Common examples – Logger, Database Connections, Thread Pool etc.
Threading:
· What is the purpose of the lock statement in C#?
o Prevents multiple threads from accessing a shared resource simultaneously.
· How does the Task Parallel Library (TPL) improve multithreading in C#?
o Simplifies the process of adding parallelism and concurrency to applications.
NuGet Packages:
· What is NuGet, and how is it used in C# projects?
o Package manager for .NET projects, used to install, update, and manage dependencies.
· Explain the role of a package manager in software development.
o Manages libraries and tools used in a project, ensuring version compatibility.
Performance Optimization:
· How can you optimize the performance of a C# application?
o Techniques include minimizing database queries, using efficient algorithms, and optimizing memory usage.
· Discuss the benefits and limitations of using the StringBuilder class for string manipulation.
o Efficient for string manipulation as it reduces memory overhead compared to string concatenation.
TOTALS
Best Score Candidate Score
(Answer between 1 and 5)
5 3 Scale
5 3 1
2
3
5 3 4
5
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
nciple, and dependency inversion principle.
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
5 3
210 126
Unable to answer the question, unaware of the concept, or provided incorrect answer
Requires help or partially answers the question
Provides an answer that is technically correct.
Provides a correct answer and is familiar with the concept.
Provides a correct answer, expands with details, and provides an example.