C# DotNet Interview Preparation - Part 9
C# Dot Net Interview Preparation Part 9

C# DotNet Interview Preparation - Part 9


Question 49: What is the difference between abstract class and interface in C#?

Answer:

Feature Abstract Class Interface Methods Can have abstract & non-abstract methods Only abstract methods (default in C# 7 and earlier) Fields Can have fields Cannot have fields Access Modifiers Supports access modifiers No access modifiers (all are public) Multiple Inheritance Not supported (only single inheritance) Supported (a class can implement multiple interfaces)

Code Example:


Question 50: What is a delegate in C#?

Answer: "A delegate is a type that holds a reference to a method, allowing methods to be passed as parameters."

Code Example:


Question 51: What is an event in C#?

Answer: "An event is a special kind of delegate used for implementing the observer pattern, where one object notifies others about a state change."

Code Example:


Question 52: What is the difference between Task and Thread in C#?

Answer:

  • Thread: A low-level unit of execution that runs independently.

  • Task: A high-level abstraction over threads, used for managing asynchronous operations efficiently.

Code Example:


Question 53: What is async and await in C#?

Answer: "async and await are used for writing asynchronous code, improving performance by preventing blocking operations."

Code Example:


Question 54: What is Dependency Injection (DI) in .NET?

Answer: "Dependency Injection (DI) is a design pattern used in .NET to manage dependencies, improving code maintainability and testability."

Code Example:


Hashtags for LinkedIn/YouTube Video:

  • #DotNetInterviewPrep

  • #CSharpProgramming

  • #LearnDotNet

  • #DotNetBeginners

  • #TechInterviews

  • #CodingTips

  • #SoftwareDevelopment

  • #InterviewQuestions

  • #AspNetCore

  • #DotNetFramework


To view or add a comment, sign in

Others also viewed

Explore topics